<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String title = "信息综合系统"; 
%>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<%@ page import="java.util.Calendar"%>
<title><%=title%>-流向查询</title>
<script>
function goDown(){
	if(total >= 20001){
		layer.alert("下载的数据量不能超过2万条，如想大数据量下载，请点击如下链接:<a href=\"${pageContext.request.contextPath }/plans/download_plansUI.do\">点我前往【流向下载】</a>");
	} else {
		location.href = "${pageContext.request.contextPath}/plan/download.do";
	}
}
function goDownAll(){
	if(total >= 20001){
		layer.alert("下载的数据量不能超过2万条，如想大数据量下载，请点击如下链接:<a href=\"${pageContext.request.contextPath }/plans/download_plansUI.do\">点我前往【流向下载】</a>");
	} else {
		location.href = "${pageContext.request.contextPath}/plan/downloadAll.do";
	}
}
</script>
<meta name="viewport"content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-itunes-app" content="app-id=429849944" />
<meta name="apple-touch-fullscreen" content="no" />
<meta content="telephone=no" name="format-detection" />
<meta name="apple-mobile-web-app-capable" content="no" />

<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
</head>
<!-- BEGIN BODY -->
<body class="fixed-top" style="background: #fff;">
	<div class="modal fade" data-backdrop="static" tabindex="-1" style="z-index: 19991017;position: absolute;" 
		id="myModal2">
		<!--窗口声明：-->
		<div class="modal-dialog modal-lg" >
			<!-- 内容声明 -->
			<div class="modal-content">
				<br>
				<p style="margin-left: 15px;">
					<b>拼命执行中，请稍等 ……</b>
				</p>
				<!-- 主体 -->
				<div class="modal-body" style="text-align: center">
					<img src="${pageContext.request.contextPath}/img/loading2.gif" alt="拼命执行中，请稍等……" >
				</div>
			</div>
		</div>
	</div>
	
	<div class="modal fade" data-backdrop="static" tabindex="-1" style="z-index: 19991016;position: absolute;" 
		id="myModal1">
		<!--窗口声明：-->
		<div class="modal-dialog modal-lg" >
			<!-- 内容声明 -->
			<div class="modal-content">
				<br>
				<p style="margin-left: 15px;">
					拼命下载中，请稍等 <span id="miao"></span> ……
				</p>
				<!-- 主体 -->
				<div class="modal-body">
					<div class="progress progress-info progress-striped">
						<div id="sucessufl_bar" class="bar" style="width: 1%"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	
	<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<ul class="breadcrumb" style="padding-bottom : 12px;background: #fff;">
							<li>
							<a href="${pageContext.request.contextPath}/user/index.do">
	                   		<i class="icon-angle-left"></i>
							<i class="icon-angle-left"></i> &nbsp;&nbsp;
	                   		首页控制台</a> 
							<span class="divider">/</span></li>
							<li class="active">流向管理</li>
							<li class="pull-right search-wrap">
							<button
							 onclick="toggleCondi();" 
							 class="btn dropdown-toggle" data-toggle="dropdown">
							<span id="but_text">隐藏筛选区域</span> 
							<i id="toggleCondi_i" class="icon-angle-up"></i>
							</button>
								&nbsp;&nbsp;
								<div class="btn-group pull-right">
									<button class="btn dropdown-toggle" data-toggle="dropdown">
										更多 <i class="icon-angle-down"></i>
									</button>
									<ul class="dropdown-menu pull-right">
										<li>
										<a href="#" onclick="goDown()">下载已筛选模板字段流向</a></li>
										<li>
										<a href="#" onclick="goDownAll()">下载已筛选【所有】字段流向</a></li>
										<li><a href="#" onclick="openUpload();">Excel批量上传N条</a></li>
										<li><a href="#" onclick="showOpen(0,'新增流向');">页面新增一条</a></li>
										<li><a href="#" onclick="deletePlan();">页面通过Id删除流向</a></li>
										<li><a href="#" onclick="byIdOpen();">根据Id修改流向属性</a></li>
										<li><a href="#" onclick="showKanWu();">页面勘误流向</a></li>
										<li><a href="#" onclick="openUploadKanWu()">Excel批量上传勘误表</a></li>
										<li><a href="${pageContext.request.contextPath}/plan/errata_download.do?i=<%=Math.random() %>">下载勘误表模板</a></li>
										<li><a href="#" onclick="openUploadTime()">下载时间理论库存</a></li>
										<li><a href="#" onclick="initpolicy()">给销售或纯销流向赋值政策</a></li>
										<li><a href="#" onclick="openStatus();">费用押待毕</a></li>
										<li><a href="#" onclick="systemBL()">系统提单</a></li>
										<li><a href="#" onclick="calculateTCOpen();">系统计算提成</a></li>
										<!-- <li><a href="#" onclick="changePrice();">修改开票价、协议测算价</a></li> -->
									</ul>
								</div>	
							</li>
						</ul>
					</div>
				</div>
				<!-- BEGIN EDITABLE TABLE widget-->
				<div class="row-fluid">
					<div class="span12">
						<!-- BEGIN EXAMPLE TABLE widget-->
						<div class="purple">
							<div class="widget-body">
								<div>
									<div class="clearfix">
										<form id="filterForm">
										<input type="text" class="span2" name="id" id="plansId" ondblclick="clearText('plansId')"
											placeholder="填写流向ID" data-provide="typeahead" data-items="4" />

										<input type="text" class="span1 typeahead" name="mgr" id="mgr" ondblclick="clearText('mgr')"
											placeholder="填写经理" data-provide="typeahead" data-items="4" />

										<input type="text" class="span2 typeahead" name="zhenghe_qs" id="terminalQs" ondblclick="clearText('terminalQs')"
											placeholder="填写Qs名" data-provide="typeahead" data-items="4" />

										<input type="text" class="span1 typeahead" name="fenbu" id="fenbu" ondblclick="clearText('fenbu')"
											placeholder="填写分部" data-provide="typeahead" data-items="4" />

										<input type="text" class="span1 typeahead" name="daibiao" id="daibiao" ondblclick="clearText('daibiao')"
											placeholder="填写代表" data-provide="typeahead" data-items="4" />
                                        <input type="text" class="span1 typeahead" ondblclick="clearText('client')"
                                            name ="client" id="client" placeholder="填写客户" data-provide="typeahead"
                                            data-items="4" /> 
										<input type="text" class="span2 typeahead" id="tichengbelong" ondblclick="clearText('tichengbelong')"
											name="tichengbelong" placeholder="填写提成人" data-provide="typeahead"
											data-items="4" /> 
											
										<input type="text" class="span2 typeahead" ondblclick="clearText('terminal')"
											name="terminal" id="terminal" placeholder="填写入货乙方" data-provide="typeahead"
											data-items="4" /> 
										<input type="text" class="span2 typeahead" ondblclick="clearText('commercial1')"
											name="commercial1" id="commercial1" placeholder="填写出货甲方"
											data-provide="typeahead" data-items="4" /> 
										<input
											type="text" class="span2" name="clientpolicyId" id="policyId" placeholder="填写协议ID" ondblclick="clearText('policyId')"
											data-provide="typeahead" data-items="4" /> 
											 <select name="year"
											id="year" multiple="multiple" size="1"
											class="input-medium m-wrap">
											<option value="-1" disabled>请选择年份</option>
											<%
												Calendar cal = Calendar.getInstance();
												int year = cal.get(Calendar.YEAR) - 4;
												String str = String.valueOf(year);
												for (int i = 0; i < 5; i++) {
											%>
											<option value="<%=year%>"><%=year%></option>
											<%
												year = year + 1;
												}
											%>
										</select> 
										<select id="month" multiple="multiple" size="1"
											class="input-medium m-wrap" name="mouth">
											<option value="-1" disabled>请选择月份</option>
											<option value="01">01</option>
											<option value="02">02</option>
											<option value="03">03</option>
											<option value="04">04</option>
											<option value="05">05</option>
											<option value="06">06</option>
											<option value="07">07</option>
											<option value="08">08</option>
											<option value="09">09</option>
											<option value="10">10</option>
											<option value="11">11</option>
											<option value="12">12</option>
										</select>
										<select id="judge" multiple="multiple" size="1" name="judge">
											<option value="-1" disabled>请选择行为</option>
											<option value="入库">入库</option>
											<option value="销售">销售</option>
											<option value="调拨">调拨</option>
											<option value="纯销">纯销</option>
											<option value="另付">另付</option>
											<option value="转移">转移</option>
											<option value="期初">期初</option>
										</select>
										<select id="xieyizhuangtai" multiple="multiple" size="1"
											name="xieyizhuangtai" class="input-medium m-wrap">
											<option value="-1" disabled>请选择条线</option>
											<option value="Rx">Rx</option>
											<option value="OTC">OTC</option>
										</select> 
										 <select id="product" multiple="true" size="1"
											name="product" class="input-medium m-wrap">
											<option value="-1" disabled>请选择品种</option>
											<option value="A">A</option>
											<option value="Y">Y</option>
											<option value="Z">Z</option>
											<option value="B">B</option>
										</select> <select id="pack" name="pack" multiple="multiple" size="1">
											<option value="-1" disabled>请选择包装</option>
											<option value = "5" >5</option>
											<option value = "10" >10</option>
											<option value = "12" >12</option>
				                            <option value = "24" >24</option>
				                            <option value = "36" >36</option>
				                            <option value = "48" >48</option>
				                            <option value = "20" >20</option>
				                            <option value = "30" >30</option>
				                            <option value = "40" >40</option>
				                            <option value = "60" >60</option>
				                            <option value = "240" >240</option>
				                            <option value = "480" >480</option>
										</select> 
										 <select id="daqu" multiple="multiple" size="1"
											name="daqu" class="input-medium m-wrap">
											<option value="-1" disabled>请选择大区</option>
											<c:forEach items="${provinceList}" var="province">
												<option value="${province}">${province}</option>
											</c:forEach>
										</select> <select id="space" name="space" multiple="multiple" size="1"
											class="input-medium m-wrap">
											<option value="-1" disabled>请选择片区</option>
											<c:forEach items="${spaceList}" var="space">
												<option value="${space}">${space}</option>
											</c:forEach>
										</select> 
										<select id="province" name="province" multiple="multiple" size="1">
											<option value="-1" disabled>请选择省份</option>
											<c:forEach items="${condiMap.shengfen}" var="shenfen">
												<option value="${shenfen}">${shenfen}</option>
											</c:forEach>
										</select>
										<select id="city" name="city" multiple="multiple" size="1"
											class="input-medium m-wrap">
											<option value="-1" disabled>请选择地市</option>
											<c:forEach items="${citys}" var="city"
												varStatus="status">
												<option value="${city}">${city}</option>
											</c:forEach>
										</select>
										<select id="county" name="county" multiple="multiple" size="1"
											class="input-medium m-wrap">
											<option value="-1" disabled>请选择区县</option>
											<c:forEach items="${countrys}" var="country">
												<option value="${country}">${country}</option>
											</c:forEach>
										</select> 
										 <select id="mode" name="mode" multiple="multiple" size="1">
											<option value="-1" disabled>请选择模式</option>
											<option value="小包">小包</option>
											<option value="自营">自营</option>
											<option value="转移">转移</option>
											<option value="大包">大包</option>
											<option value="预付">预付</option>
											<option value="虚拟小包">虚拟小包</option>
											<option value="虚拟预付">虚拟预付</option>
											<option value="承包-预付">承包-预付</option>
											<option value="承包-小包">承包-小包</option>
										</select> <select id="terminaltype" name="terminaltype" multiple="multiple" size="1"
											class="input-medium m-wrap">
											<option value="-1" disabled>请选择渠道</option>
											<option value="T1">T1</option>
											<option value="T2">T2</option>
											<option value="T3">T3</option>
											<option value="T4">T4</option>
										</select> 
										
                                        <select id="tcstatus" name="tcstatus" multiple="multiple" size="1"
                                            class="input-medium m-wrap">
                                            <option value="-1" disabled>请选择提成状态</option>
                                            <option value="押">押</option>
                                            <option value="待">待</option>
                                            <option value="毕">毕</option>
                                        </select>
                                        <select id="status1" name="status1" multiple="multiple" size="1"
                                            class="input-medium m-wrap">
                                            <option value="-1" disabled>请选择1状态</option>
                                            <option value="押">押</option>
                                            <option value="待">待</option>
                                            <option value="毕">毕</option>
                                        </select>
                                        <select id="status3" name="status3" multiple="multiple" size="1"
                                            class="input-medium m-wrap">
                                            <option value="-1" disabled>请选择3状态</option>
                                            <option value="押">押</option>
                                            <option value="待">待</option>
                                            <option value="毕">毕</option>
                                        </select>
                                        <select id="status4" name="status4" multiple="multiple" size="1"
                                            class="input-medium m-wrap">
                                            <option value="-1" disabled>请选择4状态</option>
                                            <option value="押">押</option>
                                            <option value="待">待</option>
                                            <option value="毕">毕</option>
                                        </select>
                                        <select id="status5" name="status5" multiple="multiple" size="1"
                                            class="input-medium m-wrap">
                                            <option value="-1" disabled>请选择5状态</option>
                                            <option value="押">押</option>
                                            <option value="待">待</option>
                                            <option value="毕">毕</option>
                                        </select>
                                        <select id="statusMgr" name="statusMgr" multiple="multiple" size="1"
                                            class="input-medium m-wrap">
                                            <option value="-1" disabled>请选择业务员奖励状态</option>
                                            <option value="押">押</option>
                                            <option value="待">待</option>
                                            <option value="毕">毕</option>
                                        </select>
                                        
                                        <select id="kaipiaofangshi" name="kaipiaofangshi" multiple="multiple" size="1"
											class="input-medium m-wrap">
											<option value="-1" disabled>请选择票据方案</option>
											<option value="方案1">方案1</option>
											<option value="方案2">方案2</option>
											<option value="方案3">方案3</option>
										</select> <select id="jsmode" name="jsmode" multiple="multiple" size="1"
											class="input-medium m-wrap">
											<option value="-1" disabled>请选择结算方式</option>
											<option value="押1月结">押1月结</option>
											<option value="押2月结">押2月结</option>
											<option value="押批押1月结">押批押1月结</option>
											<option value="押批次月结">押批次月结</option>
											<option value="次月结">次月结</option>
										</select> 
										 
										<select id="later" name="money6" class="input-medium m-wrap" style="width: 150px;">
											<option value="-1">是否为晚交流向</option>
											<option value="1">是</option>
											<option value="0">否</option>
										</select> 
										<select id="plan_check" name="status6"
											class="input-medium m-wrap" style="width: 150px;">
											<option value="-1">是否为真自然流</option>
											<option value="1">是</option>
											<option value="0">否</option>
										</select> 
										<select id="unqualified"
											class="input-medium m-wrap" style="width: 150px;">
											<option value="-1">是否为不合规流向</option>
											<option value="1">是</option>
											<option value="0">否</option>
										</select> 
										<select id="isToday" name="today" class="input-medium m-wrap" style="width: 150px;">
											<option value="-1">是否为今日录入</option>
											<option value="1">是</option>
											<option value="0">否</option>
										</select> <input type="button" id="seach" name="seach" value="查询"
											class="btn  btn-primary" style="margin-bottom: 10px;"
											onclick="query(pNumber,pSize);">
										<input type="reset" id="reset" name="reset" value="重置该页面" class="btn  btn-primary"
					             			style="margin-bottom: 10px;" onclick="resetf();"/>
					             		<input type="button" id="calsum" name="calsum" value="计算总和" class="btn  btn-primary"
                                            style="margin-bottom: 10px;" onclick="calSum();"/>
					                    </form>
									</div>
                <div id="uploadFileForm" hidden>
                    <div class="modal-body" >
                         <form action="${pageContext.request.contextPath}/plan/upload.do?i=<%=Math.random() %>"
								method="post" id="uploadForm" enctype="multipart/form-data">
									点击该按钮选择文件:<input type="file" name="excelFile" multiple="multiple"
										class="input-medium" id="file"><br />
						 </form>
                    </div>
                </div>
                
                <div id="uploadKanWuDiv" hidden>
                    <div class="modal-body" >
                         <form action="${pageContext.request.contextPath}/plan/errataUpload.do?i=<%=Math.random() %>"
								method="post" id="uploadKanWuForm" enctype="multipart/form-data">
									点击该按钮选择文件:<input type="file" name="kanwuExcel" multiple="multiple"
										class="input-medium" id="KanWuFile"><br />
						 </form>
                    </div>
                </div>
                
                <div id="changePriceDiv" hidden>
                    <div class="modal-body" >
                        <table>
                           <tr>
                               <td>流向ID:</td>
                               <td>
                                   <input type="text" class="span3" name="idD" id = "kaipiaojiaId" value="" placeholder="多个ID用空格隔开 已毕流向无法修改"/>
                               </td>
                               <td>开票价:</td>
                               <td>
                                   <input type="text" 
                                   placeholder="请输入正确的开票价"
                                   class="span2" name="idD" id = "kaipiaojia" 
                                   value="" 
                                  onblur="if(!/^[0-9]+([.]{1}[0-9]+){0,1}$/.test(this.value)){layer.msg('目标月均纯销只能输入【整数或者小数】');this.value='';}"
                                   />
                               </td>
                               <td>
                                   <input style="margin-left: 15px;" type="button" value="修改开票价" onclick="updatePrice(1);" class="btn  btn-primary"/>
                               </td>
                            </tr>
                             </table>
                             <hr style="margin-top: 20px;">
                            <table>
                            <tr>
                               <td>流向ID:</td>
                               <td>
                                   <input type="text" class="span3" name="idD" id = "atsumId" value="" placeholder="多个ID用空格隔开 已毕流向无法修改"/>
                               </td>
                               <td>协议测算价:</td>
                               <td>
                                   <input type="text" class="span2"
                                   placeholder="请输入正确的协议测算价"
                                    name="idD" id = "atsumPrice" 
                                   value="" 
                                   onblur="if(!/^[0-9]+([.]{1}[0-9]+){0,1}$/.test(this.value)){layer.msg('目标月均纯销只能输入【整数或者小数】');this.value='';}"
                                    />
                               </td>
                               <td>
                                   <input style="margin-left: 15px;" type="button" value="修改测算价" onclick="updatePrice(2);" class="btn  btn-primary"/>
                               </td>
                            </tr>
                        </table>
                    </div>
                </div>
                
                <div id="deleteDiv" hidden>
                    <div class="modal-body" > 
                    	请输入要删除流向的ID:<input type="text" class="span5" name="idD" style="padding:13px 5px;" id = "idD" value="" placeholder="多个ID用空格隔开 已毕流向无法删除"/>
                     </div> 
                </div>

	<div id="updateStatusDiv" hidden>
		<div class="modal-body">
			<div id="updateStatusForm">
				<div id="frist">
					<span style="color: red;">*</span>&nbsp;
					<input type="text"
						id="ids" class="span7 noNull" 
						placeholder="请输入待更新的流向ID 多个ID用空格隔开"/>
				</div>
				
				<div id="second" style="display: inline;">
					<span style="color: red;">*</span>&nbsp;费用类型：
					<input type="checkbox" name="types" id="xiaobao" value="1" class="checkbox"/>
					<label for="xiaobao" style="display: inline;">1服务费(推广)</label> &nbsp;&nbsp;
					
					<input type="checkbox" name="types" id="fapiao" value="3" class="checkbox"/>
					<label for="fapiao" style="display: inline;" >3服务费(发票)</label> &nbsp;&nbsp;
					
					<input type="checkbox" name="types" id="dabiao" value="4" class="checkbox"/>
					<label for="dabiao" style="display: inline;">4服务费(达标)</label>&nbsp;&nbsp;
					
					<input type="checkbox" name="types" id="kaifa" value="5" class="checkbox"/>
					<label for="kaifa" style="display: inline;">5开发奖励</label>&nbsp;&nbsp;
					
					<input type="checkbox" name="types" id="ywy_jianli" value="ywy" class="checkbox"/>
					<label for="ywy_jianli" style="display: inline;">业务员奖励</label> &nbsp;&nbsp;
					
					<input type="checkbox" name="types" id="ticheng" value="tc" class="checkbox"/>
					<label for="ticheng" style="display: inline;">提成</label> &nbsp;&nbsp;
				</div>
				<div style="float:left;width:100%;margin-top: 2px;">
                    <span style="color: red;">*</span>&nbsp;结算状态：
                        <input type="radio" name="statusType" id="ya" value="押"
                            class="radio" /><label for="ya" style="display: inline;">押</label>&nbsp;&nbsp;
                        
                        <!-- <input type="radio" name="statusType" id="dai" value="待"
                            class="radio" /><label for="dai" style="display: inline;">待</label>&nbsp;&nbsp; -->
                        
                        <input type="radio" name="statusType" id="bi" value="毕"
                            class="radio" /><label for="bi" style="display: inline;">毕</label>&nbsp;&nbsp;
                        
                        <input type="radio" name="statusType" id="yabi" value="押毕"
                            class="radio" /><label for="yabi" style="display: inline;">押毕</label>&nbsp;&nbsp;
                        <input type="radio" name="statusType" id="chongzhangbi" value="冲账毕"
                            class="radio" /><label for="chongzhangbi" style="display: inline;">冲账毕</label>&nbsp;&nbsp;
                </div>
                <div style="float:left;width:100%; margin-top:2px;">
                    <label style = "float:left;">毕日期：</label>
                    <input type="text" id="endDate" class="Wdate span3"
                            style="width: 120px;"
                            onfocus="WdatePicker({dateFmt:'yyyy/MM/dd',lang:'zh-cn',readOnly:false})" />
                    <br>
                    <input type="text" id="memo" class="span4" 
                        placeholder="请填写毕备注"/>
                        
                    <label style = "float:left;color:red;">注意：流向一旦【毕】操作后，将被锁定，无法修改，若数据有误，领导审批后，请进行【冲账毕】操作！</label>
                </div>
                   
			</div>
		</div>
	</div>
<div id="errorInfoDiv" hidden="hidden">
	<table class="table table-striped table-hover table-bordered" style="font-size:11px;color:red;width:750px;margin:12px;">
		<thead>
			<tr>
				<td>出错行号</td>
				<td>出错标题</td>
				<td>标准字段</td>
				<td class="errorInfos">错误字段</td>
			</tr>
		</thead>
		<tbody id="error-body"></tbody>
	</table>
</div>

<div id="calSumDiv" hidden="hidden">
    <table class="table table-striped table-hover table-bordered" style="font-size:11px;width:750px;margin:12px;">
        <thead>
            <tr>
                <td>模式</td>
                <td>数量总和</td>
                <td>折量总和</td>
                <td>1金额总和</td>
                <td>3金额总和</td>
                <td>4金额总和</td>
                <td>总费用总和</td>
                <td>5金额总和</td>
                <td>业务员奖励总和</td>
            </tr>
        </thead>
        <tbody id="sum-body"></tbody>
    </table>
</div>

									<div id="keyTerminalDiv" hidden>
										<div class="modal-body">
											<div id="keyTerminalForm">
												ID：<input type="text" id="keyTerminalId" style="padding:13px 5px;"
													class="span3 typeahead noNull" value=""
													onblur="blurCheck(this);" />&nbsp;<span style="color: red;">*</span>
												<br/>
												<label style="display: inline;" id="key">重点终端</label>： <input
													type="text" class="span5 typeahead" id="terminalName"
													data-provide="typeahead" data-items="4"
													style="display: inline;padding:13px 5px;" readonly /> </br>分组标识:
												<div id="GroupFlag" style="display: inline;">
													<input type="radio" name="group" id="yes" value="1"
														onclick="" checked="checked" class="radio" /> <label
														for="yes" style="display: inline;">是</label> <input
														type="radio" name="group" id="no" value="0" onclick=""
														class="radio" /> <label for="no" style="display: inline;">否</label>
												</div>
												<br/>修订标识:
												<div id="reviseFlag" style="display: inline;">
													<input type="radio" name="revise" id="E" value="E"
														onclick="chooseRevise('E');" checked="checked"
														class="radio"></input><label for="E"
														style="display: inline;">修改</label> <input type="radio"
														name="revise" id="N" value="N"
														onclick="chooseRevise('N');" class="radio"></input><label
														for="N" style="display: inline;">新增</label>
												</div>
											</div>
										</div>
									</div>

									<div id="updateByIdDiv" hidden>
										<div class="modal-body">
											<form action="${pageContext.request.contextPath }/plan/updatePlanByID.do" method="post"
												id="updateByIdForm">
												<span style="color: red;">*</span>&nbsp;ID:
												<input
													id="updatesId" value="" type="text" class="span5 noNull" name="id" 
													class="noNull" />
													<br/>
												片区提成人：<input
													type="text" class="span2" value=""
													name="tichengbelong" id="tichengbelongs" 
													data-provide="typeahead" data-items="4" /> 
												大区提成人：<input
                                                    type="text" class="span2" value=""
                                                    name="daquTcMan" id="daquTcMan" 
                                                    data-provide="typeahead" data-items="4" /> <br/>
												经理：<input
													type="text" value="" id="mgrs" class="span2" 
													data-provide="typeahead" name="mgr" data-items="4" /> 
												条线：<select id="tiaoxian"
													name="xieyizhuangtai">
													<option value=""></option>
													<option value="Rx">Rx</option>
													<option value="OTC">OTC</option>
												</select>
												<br>
												客户：<input
													type="text" value="" id="clientI" class="span2" 
													data-provide="typeahead" name="client" data-items="4" /> 
												代表：<input
													type="text" value="" id="daibiaoI" class="span2" 
													data-provide="typeahead" name="daibiao" data-items="4" /> 
											</form>
										</div>
									</div>
									<div id="calculateTCDiv" hidden>
										<div class="modal-body">
											<button value="Q1" onclick="calculateTC(this.value);"
												class="btn  btn-primary">Y18Q1提成</button>
											<button value="Q2" onclick="calculateTC(this.value);"
												class="btn  btn-primary">Y18Q2提成</button>
											<button value="Q3" onclick="calculateTC(this.value);"
												class="btn  btn-primary">Y18Q3提成</button>
											<button value="Q4" onclick="calculateTC(this.value);"
												class="btn  btn-primary">Y18Q4提成</button>
										</div>
									</div>
									
									<div id="timeDiv" hidden>
										<div class="modal-body">
											请输入库存截至日期：<input type="text" name="endTime" id="endTime"
												 class="Wdate" style="width: 120px;padding: 13px 5px;" 
												 value = ""
												onfocus="WdatePicker({isShowClear:false,readOnly:false,dateFmt:'yyyy/MM/dd'})" />
										</div>
									</div>
									
									<div id="systemBLDiv" hidden>
										<div class="modal-body">
											<input type="button" id="allSpace" name="allSpace" value="全国提单"
											class="btn  btn-primary" style="margin-bottom: 10px;" onclick = "spaces_BL('all');"/>
											<input type="button" id="allSpace" name="spaces" value="片区提单"
											class="btn  btn-primary" style="margin-bottom: 10px;" onclick = "spacesBL();"/>
										</div>
									</div>
									
									<div id="spacesDiv" hidden>
										<div style="padding:20px;">
											<p style="display: inline">请选择片区：</p>
					                        <select id="spaceBL" multiple="multiple" size="1" class="input-medium m-wrap" >
					                            <c:forEach items="${condiMap.space}" var="space" varStatus="status">
					                                <option value="${space}">${space}</option>
					                            </c:forEach>
					                        </select>
										</div>
									</div>
									
									<div id="initDiv" hidden>
										<div class="modal-body">
											销售或纯销流向ID：<input type="text" class="span5" name="plan_Id" id="plan_Id" 
                            					style="padding:13px 5px;"/><br/>
                           					匹配协议ID：<input type="text" class="span5" name="policy_Id" id="policy_Id" 
                           					style="padding:13px 5px;"/>
										</div>
									</div>
									
				<div id="kanWuDiv" hidden>
                    <div class="modal-body" style="height: 90%">
                    <form action="" method="post" id="kanWuForm">
                        <input id="gfIdU"  name="id" type="text" placeholder="请输入流向ID 多个用空格隔开" style="padding:13px 5px;"/>
                        <input type="text" class="span3 typeahead " name="errataDTO.zhenghe_qs" id="zhenghe_qsU" placeholder="请填写QS名" data-provide="typeahead"
                            data-items="4" style="padding:13px 5px;"/>
                        <input type="text" class="span3 typeahead " name="errataDTO.fenbu" id="zhenghe_qsU" placeholder="请填写分部" data-provide="typeahead"
                            data-items="4" style="padding:13px 5px;"/>
                        <br/>
                        <input type="text" style="padding:13px 5px;" class="span2 typeahead " name="errataDTO.mgr" style="width:100px;" id="mgrU" placeholder="请填写经理" data-provide="typeahead"
                        	data-items="4"  />
                        <input type="text" class="span3 typeahead " name="errataDTO.terminallev" id="terminallevU" placeholder="请填写级别" data-provide="typeahead"
                        	data-items="4" style="padding:13px 5px;"/>
                        <input type="text" style="padding:13px 5px;" class="span2 typeahead " name="errataDTO.daibiao" style="width:100px;" id="daibiaoU" placeholder="请填写代表" data-provide="typeahead"
                            data-items="4" />
                        <input type="text" class="span2 typeahead " name="errataDTO.tichengbelong"  id="tichengbelongU" placeholder="请填写提成受益人" data-provide="typeahead"
                        	data-items="4" style="padding:13px 5px;"/>
                        <br/>
                        <p style="display: inline">请选择条线：</p>
                        <select id="xieyizhuangtaiU" size="1" name="errataDTO.xieyizhuangtai" class="input-medium m-wrap">
							<option value="" ></option>
							<option value="Rx">Rx</option>
							<option value="OTC">OTC</option>
						</select> 
						<p style="display: inline">请选择渠道：</p>
                        <select id="terminaltypeU" name="errataDTO.terminaltype" size="1" class="input-medium m-wrap">
							<option value="" ></option>
							<option value="T1">T1</option>
							<option value="T2">T2</option>
							<option value="T3">T3</option>
							<option value="T4">T4</option>
						</select>
                        <p style="display: inline">请选择模式：</p>
                        <select id="errataDTO.mode" name="errataDTO.pmode" size="1" style="width:120px;">
							<option value="" ></option>
							<option value="小包">小包</option>
							<option value="自营">自营</option>
							<option value="转移">转移</option>
							<option value="大包">大包</option>
							<option value="预付">预付</option>
							<option value="虚拟小包">虚拟小包</option>
							<option value="虚拟预付">虚拟预付</option>
							<option value="承包-预付">承包-预付</option>
							<option value="承包-小包">承包-小包</option>
						</select>
						<br/>
						<p style="display: inline">请选择晚交流向标识</p>
                       <select id="later" name="errataDTO.money6" class="input-medium m-wrap" style="width: 150px;">
							<option value=""></option>
							<option value="晚交流向">是</option>
							<option value="正常流向">否</option>
						</select> 
						<p style="display: inline">请选择真自然流向标识</p>
						<select id="plan_check" name="errataDTO.status6" class="input-medium m-wrap" style="width: 150px;">
							<option value="" ></option>
							<option value="真自然流">是</option>
							<option value="假自然流">否</option>
						</select> <br/>
                        <p style="display: inline">请选择省份：</p>
                        <select id="provinceU"  size="1" class="input-medium m-wrap" name="errataDTO.province">
                        	<option value=""></option>
                            <c:forEach items="${condiMap.shengfen}" var="shenfen" varStatus="status">
                                <option value="${shenfen}">${shenfen}</option>
                            </c:forEach>
                        </select>
                        <p style="display: inline">请选择地市：</p>
                        <input type="text" style="padding:13px 5px;" class="span2 typeahead " name="errataDTO.city" style="width:100px;" id="cityU" placeholder="请填写地市" data-provide="typeahead"
                               data-items="4" />
                        <p style="display: inline">请选择区县：</p>
                        <input type="text" style="padding:13px 5px;" class="span2 typeahead " name="errataDTO.county" style="width:100px;" id="countyU" placeholder="请填写区县" data-provide="typeahead"
                               data-items="4"/>    <br/>
                        <p style="display: inline">请选择大区：</p>
                        <select id="daquU" class="input-medium m-wrap" name="errataDTO.daqu">
                        	<option value=""></option>
                            <c:forEach items="${condiMap.province}" var="province" varStatus="status">
                                <option value="${province}">${province}</option>
                            </c:forEach>
                        </select>
                        <p style="display: inline">请选择片区：</p>
                        <select id="spaceU"  size="1" class="input-medium m-wrap" name="errataDTO.space">
                        	<option value=""></option>
                            <c:forEach items="${condiMap.space}" var="space" varStatus="status">
                                <option value="${space}">${space}</option>
                            </c:forEach>
                        </select>
                        <br/><p style="display: inline">请填写流向备注：</p>
                        <textarea rows="3" cols="80" name ="errataDTO.demo" id="demoU" placeholder="请填写流向备注"></textarea>
                        </form>
                    </div>
                </div>
									
									<div id="updatePlanForm" hidden>
										<div class="modal-body" style="height: 90%">
											<form action="${pageContext.request.contextPath }/plan/addPlan.do" method="post" id="planForm">
												<input id="planIdU" value="" hidden="hidden" 
													name="id" /> <span style="color: red;">*</span>&nbsp;请填写客户：
												<input type="text" name="client" style="width: 100px;padding: 13px 5px;"
													id="clientU" data-provide="typeahead" data-items="4"
													class="span2 typeahead input-medium m-wrap noNull" /> <span
													style="color: red;">*</span>&nbsp;请填写入货乙方: <input
													type="text" name="terminal" class="span4 typeahead noNull"
													style="width: 350px;padding: 13px 5px;" id="terminalU"
													data-provide="typeahead" data-items="4" /></br> <span
													style="color: red;">*</span>&nbsp;请填写出货甲方: <input
													type="text" name="commercial1"
													class="span3 typeahead noNull" style="width: 350px;padding: 13px 5px;"
													id="commercial1U" data-provide="typeahead" data-items="4" /></br>
												<span style="color: red;">*</span>&nbsp;请填写数量: <input
													type="text" name="count" class="span3 typeahead noNull"
													style="width: 100px;padding: 13px 5px;" id="countU"
													onblur="if(!/^\d{1,9}$/.test(this.value)){layer.msg('只能输入数字');this.value='';}" />
												<span style="color: red;">*</span>
												请填写批号: <input type="text" name="pihao"
													class="span3 typeahead noNull" style="width: 100px;padding: 13px 5px;"
													id="pihaoU" /> <span style="color: red;">*</span>&nbsp;请填写销售日期:
												<input type="text" name="sdate" id="sdateU"
													 class="Wdate" style="width: 120px;padding: 13px 5px;"
													onfocus="WdatePicker({isShowClear:false,readOnly:false,dateFmt:'yyyy/MM/dd'})" />
												<br/> 是否晚交: <select id="laterU" name="money6"
													class="input-medium m-wrap">
													<option value="">否</option>
													<option value="晚交流向">是</option>
												</select> 
												
												是否为自然流: 
												<select id="plan_checkU" name="status6"
													class="input-medium m-wrap">
													<option value="假自然流">否</option>
													<option value="真自然流">是</option>
												</select>
												是否为不合规流向: 
												<select id="unqualifiedU" name="unqualified"
													class="input-medium m-wrap">
													<option value="">否</option>
													<option value="不合规流向">是</option>
												</select>
												<br/>
												<span style="color: red;">*</span>&nbsp;请选择条线: <select
													id="xieyizhuangtaiU" size="1" class="input-medium m-wrap" name="xieyizhuangtai">
													<option value="Rx">Rx</option>
													<option value="OTC">OTC</option>
												</select> <span style="color: red;">*</span>&nbsp;请选择品种： <select
													id="productU" size="1" class="input-medium m-wrap" name="product">
													<option value="A">A</option>
													<option value="Y">Y</option>
													<option value="Z">Z</option>
													<option value="B">B</option>
												</select> <span style="color: red;">*</span>&nbsp;请选择行为: <select
													id="judgeU" size="1" class="input-medium m-wrap" name="judge" >
													<option value="入库">入库</option>
													<option value="销售">销售</option>
													<option value="调拨">调拨</option>
													<option value="纯销">纯销</option>
													<option value="另付">另付</option>
													<option value="转移">转移</option>
													<option value="期初">期初</option>
												</select></br> <span style="color: red;">*</span>&nbsp;请选择包装: <select
													id="packU" size="1" class="input-medium m-wrap" name="pack">
													<option value = "5" >5</option>
													<option value = "10" >10</option>
													<option value = "12" >12</option>
							                         <option value = "24" >24</option>
							                         <option value = "36" >36</option>
							                         <option value = "48" >48</option>
							                         <option value = "20" >20</option>
							                         <option value = "40" >40</option>
							                         <option value = "30" >30</option>
							                         <option value = "60" >60</option>
							                         <option value = "240" >240</option>
							                         <option value = "480" >480</option>
												</select> <span style="color: red;">*</span>&nbsp;请选择模式: <select
													id="modeU" size="1" class="input-medium m-wrap" name="mode">
													<option value="小包">小包</option>
													<option value="大包">大包</option>
													<option value="预付">预付</option>
													<option value="自营">自营</option>
													<option value="转移">转移</option>
													<option value="虚拟预付">虚拟预付</option>
													<option value="虚拟小包">虚拟小包</option>
													<option value="承包-预付">承包-预付</option>
													<option value="承包-小包">承包-小包</option>
												</select></br> 请填写备注：
												<textarea rows="3" cols="80" style="width:606px;" name ="demo" id="memoU" placeholder="请填写备注"></textarea>
											</form>
										</div>
									</div>
									
									
									<div class="row-fluid">
				                	<div class="span12">
				                    <!-- BEGIN ALERTS PORTLET-->
				                    <div class="widget blue">
				                        <div class="widget-title">
				                            <h4><i class="icon-reorder"></i>
				                                <a href="javascript:;" id="getProp" style ="color:white;margin-left:0px;">复制</a>
				                                <a href="javascript:;" onclick="scrollToLeft();" title="定位到表格最左端" style ="color:white;margin-left:0px;">最左</a>
				                                <a href="javascript:;" onclick="scrollToCenter1();" title="定位到表格稍居中" style ="color:white;">稍中</a>
				                                <a href="javascript:;" onclick="scrollToCenter2();" title="定位到表格近居中" style ="color:white;">近中</a>
				                                <a href="javascript:;" onclick="scrollToCenter();" title="定位到表格正中间" style ="color:white;">正中</a>
				                                <a href="javascript:;" onclick="scrollToRight2();" title="定位到表格最右端" style ="color:white;">稍右</a>
				                                <a href="javascript:;" onclick="scrollToRight3();" title="定位到表格最右端" style ="color:white;">近右</a>
				                                <a href="javascript:;" onclick="scrollToRight();" title="定位到表格最右端" style ="color:white;">最右</a>
				                            </h4>
				                            <span class="tools">
												<a href="javascript:;" class="icon-chevron-down"></a>
											</span>
				                        </div> 
								    
				                        <div class="widget-body" style="overflow:auto" id="canvas-wrap">
					                        <div class="pageBottom" style="text-align:center;">
	                                            <input type="hidden" id="page-size" value="3"/>
	                                            <div id="callBackPager" class="paging_bootstrap pagination"></div> 
	                                        </div>
	                                        
				                        	<table class="table table-striped table-hover table-bordered" width="2640px;"
				                           		style="table-layout:fixed;font-size: 12px;">
				                                <thead>
				                                <tr>
				                                    <th style="width:15px;">
				                                    <input type="checkbox" name="choiceAll" value="all" id ="allAndNotAll"/></th>
                                                    <th style="width:55px;">日期</th>
                                                    <th style="width:50px;">片区</th>
                                                    <th style="width:100px;">出货甲方</th>
                                                    <th style="width:25px;">行为</th>
                                                    <th style="width:100px;">入货乙方</th>
                                                    <th style="width:50px;">QS名</th>
                                                    <th style="width:95px;">省份/经理/提成人</th>
                                                    <th style="width:35px;">协议id</th>
                                                    <th style="width:60px;">协态/方案</th>
                                                    <th style="width:55px;">品规/模式</th>
                                                    <th style="width:25px;">数量</th>
                                                    <th style="width:120px;">客户/条线/代表</th>
                                                    <th style="width:50px;">结算方式</th>
                                                    <th style="width:45px;">1服务费(基础)</th>
                                                     <th style="width:40px;">1金额</th>
                                                    <th style="width:100px;">1状态</th>
                                                    <th style="width:50px;">3服务费(财务)</th>
                                                    <th style="width:40px;">3金额</th>
                                                    <th style="width:100px;">3状态</th>
                                                    <th style="width:50px;">4服务费(达标)</th>
                                                    <th style="width:40px;">4金额</th>
                                                    <th style="width:100px;">4状态</th>
                                                    <th style="width:50px;">总费用</th>
                                                    <th style="width:50px;">5开发奖励</th>
                                                    <th style="width:40px;">5金额</th>
                                                    <th style="width:100px;">5状态</th>
                                                    <th style="width:50px;">业务员奖励</th>
                                                    <th style="width:50px;">业务员奖励金额</th>
                                                    <th style="width:100px;">业务员奖励状态</th>
                                                    <th style="width:50px;">大区</th>
                                                    <th style="width:70px;">地市</th>
                                                    <th style="width:30px;">区县</th>
                                                    <th style="width:40px;">销售折量</th>
                                                    <th style="width:40px;">生产折量</th>
                                                    <th style="width:80px;">批号</th>
                                                    <th style="width:100px;">分部</th>
                                                    <th style="width:30px;">渠道</th>
                                                    <th style="width:40px;">级别</th>
                                                    <th style="width:45px;">中标价</th>
                                                    <th style="width:45px;">配送率</th>
                                                    <th style="width:45px;">开票价</th>
                                                    <th style="width:50px;">标准测算价</th>
                                                    <th style="width:50px;">协议测算价</th>
                                                    <th style="width:60px;">中标金额</th>
                                                    <th style="width:60px;">开票金额</th>
                                                    <th style="width:70px;">大区提成人</th>
                                                    <th style="width:60px;">区域主管</th>
                                                    <th style="width:70px;">贡献提成人</th>
                                                    <th style="width:90px;">片区存量来源</th>
                                                    <th style="width:90px;">片区存量提成</th>
                                                    <th style="width:90px;">片区增量来源</th>
                                                    <th style="width:90px;">片区增量提成</th>
                                                    <th style="width:115px;">片区晚交流向扣减</th>
                                                    <th style="width:115px;">片区晚交流向提成</th>
                                                    <th style="width:60px;">高阶来源</th>
                                                    <th style="width:60px;">高阶提成</th>
                                                    <th style="width:60px;">贡献来源</th>
                                                    <th style="width:60px;">贡献提成</th>
                                                    <th style="width:85px;">主管存量来源</th>
                                                    <th style="width:85px;">主管存量提成</th>
                                                    <th style="width:85px;">主管增量来源</th>
                                                    <th style="width:85px;">主管增量提成</th>
                                                    <th style="width:85px;">大区存量来源</th>
                                                    <th style="width:85px;">大区存量提成</th>
                                                    <th style="width:85px;">大区增量来源</th>
                                                    <th style="width:85px;">大区增量提成</th>
                                                    <th style="width:115px;">大区晚交流向扣减</th>
                                                    <th style="width:115px;">大区晚交流向提成</th>
                                                    <th style="width:60px;">提成备注</th>
                                                    <th style="width:60px;">提成状态</th>
                                                    <th style="width:85px;">重点终端标识</th>
                                                    <th style="width:70px;">好伙伴标识</th>
                                                    <th style="width:85px;">晚交流向标识</th>
                                                    <th style="width:100px;">真自然流向标识</th>
                                                    <th style="width:100px;">不合规流向标识</th>
                                                    <th style="width:200px;">流向备注</th>
                                                    <th style="width:60px;">收款人</th>
                                                    <th style="width:210px;">开户行</th>
                                                    <th style="width:210px;">银行账号</th>
                                                    <th style="width:50px;">流向ID</th>
                                                    <th style="width:60px;">录入人员</th>
                                                    <th style="width:60px;">录入日期</th>
                                                </tr>
				                                </thead>
				                                <tbody id="distribute-body">
				                                <input type="hidden" id="selectIds" value="${ids }"/>
				                        		</tbody>
				                            </table>
				                        </div>
				
				                    </div>
				                    <!-- END ALERTS PORTLET-->
				                	</div>
				            	</div>
                            </div>
							</div>
						</div>
					</div>
				</div>
			</div>
	
</body>

<script src="${pageContext.request.contextPath}/js/jquery-1.7.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.nicescroll.js" type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/js/fullcalendar.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.easy-pie-chart.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.sparkline.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/Chart.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.scrollTo.min.js"></script>
<script src="${pageContext.request.contextPath}/js/common-scripts.js"></script>

<script src="${pageContext.request.contextPath}/javascript/httpService.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/layer/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-multiselect.js">
</script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap-multiselect.css" type="text/css" />
<script src="${pageContext.request.contextPath}/js/bootstrap-typeahead.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/extendPagination.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="http://img3.job1001.com/js/ZeroClipboard/jquery.zclip.min.js"></script>
<script type="text/javascript">
	var mgr = ${condiMap.mgr};
	$('#mgr').typeahead({source: mgr})
	var commercial1 = ${condiMap.commercial};
	$('#commercial1').typeahead({source: commercial1})
	var terminal = ${condiMap.terminal};
	$('#terminal').typeahead({source: terminal})
	var terminalQs = ${condiMap.qsterminal};
	$('#terminalQs').typeahead({source: terminalQs})
	var fenbu = ${condiMap.fenbu};
	$('#fenbu').typeahead({source: fenbu})
	var daibiao = ${condiMap.daibiao};
	$('#daibiao').typeahead({source: daibiao})
	var tichengbelong = ${condiMap.tichengbelong};
	$('#tichengbelong').typeahead({source: tichengbelong})
	var client = ${condiMap.client};
	$('#client').typeahead({source: client})
$(document).ready(function(){
	setTimeout("selectMoreItem('product','请选择品种','110px');",10);
	setTimeout("selectMoreItem('judge','请选择行为','110px');",10);
	setTimeout("selectMoreItem('pack','请选择包装','110px');",10);
	setTimeout("selectMoreItem('mode','请选择模式','110px');",10);
	setTimeout("selectMoreItem('xieyizhuangtai','请选择条线','110px');",10);
	setTimeout("selectMoreItem('terminaltype','请选择渠道','110px');",10);
	setTimeout("selectMoreItem('jsmode','请选择结算方式','130px');",10);
	setTimeout("selectMoreItem('kaipiaofangshi','请选择票据方案','140px');",10);
	setTimeout("selectMoreItem('city','请选择地市','110px');",10);
	setTimeout("selectMoreItem('county','请选择区县','110px');",10);
	setTimeout("selectMoreItem('daqu','请选择大区','110px');",10);
	setTimeout("selectMoreItem('space','请选择片区','110px');",10);
	setTimeout("selectMoreItem('province','请选择省份','110px');",10);
	setTimeout("selectMoreItem('year','请选择年份','110px');",10);
	setTimeout("selectMoreItem('month','请选择月份','110px');",10);
	setTimeout("selectMoreItem('status1','请选择1状态','110px');",10);
	setTimeout("selectMoreItem('status3','请选择3状态','110px');",10);
	setTimeout("selectMoreItem('status4','请选择4状态','110px');",10);
	setTimeout("selectMoreItem('status5','请选择5状态','110px');",10);
	setTimeout("selectMoreItem('statusMgr','请选择业务员奖励状态','150px');",10);
	setTimeout("selectMoreItem('tcstatus','请选择提成状态','140px');",10);
	
	/***
    $('#product').multiselect({includeSelectAllOption:true, nonSelectedText: '请选择品种',includeSelectAllOption:true,buttonWidth: '110px' });
    $('#judge').multiselect({includeSelectAllOption:true, nonSelectedText: '请选择行为', buttonWidth: '110px'});
    $('#pack').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择包装',buttonWidth: '110px'});
    $('#mode').multiselect({includeSelectAllOption:true, nonSelectedText: '请选择模式',buttonWidth: '110px'});
    $('#xieyizhuangtai').multiselect({includeSelectAllOption:true, nonSelectedText: '请选择条线',buttonWidth: '110px'});
    $('#terminaltype').multiselect({includeSelectAllOption:true, nonSelectedText: '请选择渠道',buttonWidth: '110px'});
    $('#jsmode').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择结算方式',buttonWidth: '140px'});
    $('#kaipiaofangshi').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择票据方案',buttonWidth: '140px'});
    $('#city').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择地市',enableFiltering: true,maxHeight:300,buttonWidth: '110px'});
    $('#county').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择区县',enableFiltering: true,maxHeight:300,buttonWidth: '110px'});
    $('#daqu').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择大区',enableFiltering: true,maxHeight:300,buttonWidth: '110px'});
    $('#space').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择片区',enableFiltering: true,maxHeight:300,buttonWidth: '110px'});
    $('#province').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择省份',enableFiltering: true,maxHeight:300,buttonWidth: '110px'});
    $('#year').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择年份',buttonWidth: '110px'});
    $('#month').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择月份',buttonWidth: '110px'});
    $('#status1').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择1状态',enableFiltering: true,maxHeight:300,buttonWidth: '110px'});
    $('#status3').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择3状态',enableFiltering: true,maxHeight:300,buttonWidth: '110px'});
    $('#status4').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择4状态',buttonWidth: '110px'});
    $('#status5').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择5状态',buttonWidth: '110px'});
    $('#statusMgr').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择业务员奖励状态',buttonWidth: '150px'});
    $('#tcstatus').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择提成状态',buttonWidth: '140px'});
	**/
    if (window.clipboardData ) {
        $('#getProp').click(function() {
        	var ids = getProp();  
        	if(selectedIds.trim().length>0){
     		   ids = selectedIds;
     	    }
        	if(ids.trim().length>0){
        		window.clipboardData.setData("Text", ids);
                layer.msg("复制成功！"); 
                selectedIds = "";
                $("#allAndNotAll").attr("checked", false);  
                $("input[name='choice']:checkbox").each(function(){ 
                    $(this).attr("checked", false);  
              	});
        	}else{
        		layer.alert("您没有选中行！");
        	}
        });
    } else {
        $("#getProp").zclip({
            path:'http://img3.job1001.com/js/ZeroClipboard/ZeroClipboard.swf',
            copy:function(){
            	   var ids = getProp();  
            	   if(selectedIds.trim().length>0){
            		   ids = selectedIds;
            	   }
            	   if(ids.trim().length>0){
            		   return ids;
            	   }else{
            		   layer.msg("您没有选中行！");
            	   }
            	},
            afterCopy:function(){
            	$("#allAndNotAll").attr("checked", false);  
            	$("input[name='choice']:checkbox").each(function(){ 
                     $(this).attr("checked", false);  
               	});
            	layer.msg("复制成功！");
            	selectedIds = "";
            }
        });
    }
});
</script>
<script type="text/javascript">
var htmls = $("#updatePlanForm").html();
var byIdHtml = $("#updateByIdDiv").html();
var StatusHtml = $("#updateStatusDiv").html();
var keyTerminalHtml = $("#keyTerminalDiv").html();
var goodFriendHtml = $("#keyTerminalDiv").html();
var calculateTCHtml = $("#calculateTCDiv").html();
var uploadFileHtml = $("#uploadFileForm").html();
var uploadKanWuHtml = $("#uploadKanWuDiv").html();
var deleteHtml = $("#deleteDiv").html();
var kanWuHtml = $("#kanWuDiv").html();
var timeHtml = $("#timeDiv").html();
var initHtml = $("#initDiv").html();
var systemBLHtml = $("#systemBLDiv").html();
var spacesHtml = $("#spacesDiv").html();
var changePriceHtml =$("#changePriceDiv").html();
var ret = null;


function showOpen(id,type) {
    //通过ID查询basis对象
    if("修改流向"==type){
        $.ajax({
            type: "POST",
            async:false,//同步
            url: "${pageContext.request.contextPath }/plan/selectPlanByID.do?t=" + Math.random(),
            data: {planId:id},
            dataType: "json",
            success: function (result) {
            	if(result.code==-3){	//登录用户失效
               		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath }/login.jsp">登录页面</a>');
               	}else{
               		ret = result;
               	}
            },
            error: function (e) {;
                layer.closeAll('loading')
                layer.msg("操作失败！");
            }
        });
    }
    
    $("#updatePlanForm").remove();
    layer.open({
    	title: [type+'<span style="color:red;font-size:12px;margin-left:10px;">*表示该项必填</span>', 'font-size:18px;'],
        type:1,
        content: htmls, //这里content是一个普通的String
        btn: ['确认', '取消'],
        yes: function(index, layero){
        	//非空验证
        	var ret = checkNull('change');
        	if(ret=="false"){
        		return true;
        	}
        	layer.load(2);
        	var action ="";
            if("新增流向"==type){
            	action = "${pageContext.request.contextPath }/plan/changePlan.do?flag=N&t=" + Math.random();
            }else if("修改流向"==type){
            	action = "${pageContext.request.contextPath }/plan/changePlan.do?flag=E&t=" + Math.random();
            }
            $.ajax({
                type: "POST",
                url: action,
                data: $('#planForm').serialize(),
                dataType: "json",
                success: function (result) {
                	layer.closeAll('loading');
                	var code = result.code;
                	if(code==-3){	//登录用户失效
                   		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
                   	}else if(code==-4){
                        layer.alert("您没有操作权限 ！！！");
                    }else if(code>0){
                   		layer.closeAll();
                   		layer.msg(result.msg);
                    	query(pNumber,pSize);
                    }else if(code==-2){ //excel校验不通过
                    	errorInfo(result.msg,"页面修改或新增流向");
                    }else if(code==-1){ // 有错误
                    	layer.alert(result.msg);
                    }
                    return false;
                },
                error: function (e) {
                	layer.closeAll('loading');
                    layer.msg("操作失败！");
                    return true;
                }
            });
            //layer.closeAll("loading");
            return false;
        }
        ,btn2: function(index, layero){
        	layer.closeAll('loading');
        }
        ,cancel: function(){
        	layer.closeAll('loading');
        }
        ,area: ['800px', '500px']
    });
    $("#planIdU").val(id);  //动态赋值ID
    if(ret!=null&&type=='修改流向'){
        $("#clientU").val(ret.client);
        $("#terminalU").val(ret.terminal);
        $("#commercial1U").val(ret.commercial1);
        $("#countU").val(ret.count);
        $("#pihaoU").val(ret.pihao);
        $("#sdateU").val(ret.sdate);
        
        $("#laterU").val(ret.money6);
        $("#plan_checkU").val(ret.status6);
        $("#unqualifiedU").val(ret.unqualified);
        $("#xieyizhuangtaiU").val(ret.xieyizhuangtai);
        $("#productU").val(ret.product);
        $("#judgeU").val(ret.judge);
        $("#packU").val(ret.pack);
        
        $("#modeU").val(ret.mode);
        $("#memoU").val(ret.demo);
    }
    var client = ${condiMap.client};
    $('#clientU').typeahead({source: client})
    var terminal = ${condiMap.terminal};
    $('#terminalU').typeahead({source: terminal})
    var commercial = ${condiMap.commercial};
    $('#commercial1U').typeahead({source: commercial})
}

//通过ID修改提成受益人、经理、条线、客户（已毕也可以修改）
function byIdOpen() { 
	$("#updateByIdDiv").remove();
	layer.load(2);
    layer.open({
        title: ['通过ID修改流向属性'+'<span style="color:red;font-size:12px;margin-left:10px;">*表示该项必填，以下属性，已毕流向也可以修改</span>', 'font-size:18px;'],
        type:1,
        content: byIdHtml, //这里content是一个普通的String
        btn: ['解锁','确认', '取消'],
        yes: function(index, layero){
        	var id = $("#updatesId").val();
        	layer.confirm('解锁成功后，这些流向将立即受到基础库和注册库的同步更新影响，是否继续解锁？', function(){
                layer.closeAll();
                layer.msg('正在执行，请稍等……', {icon: 16}, function(){
                    layer.load(2);
                    $.ajax({
                        type: "POST",
                        url: "${pageContext.request.contextPath }/plan/notLock.do?t=" + Math.random(),
                        data: {id:id},
                        dataType: "json",
                        success: function (result) {
                            if(result.code==-3){    //登录用户失效
                                layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath }/login.jsp">登录页面</a>');
                            }else if(result.code==-4){
                                layer.alert("您没有操作权限 ！！！");
                            }else{
                                layer.alert(result.msg);
                                if(result.code>0){
                                    layer.closeAll();
                                    layer.alert("操作成功 ！！！");
                                    query(pNumber,pSize);
                                }
                            }
                            return false;
                        },
                        error: function (e) {
                            layer.closeAll('loading');
                            layer.msg("操作失败！");
                            return true;
                        }
                    });
                });
              });
        	
        }
        ,btn2: function(index, layero){
        	//非空验证
            var ret = checkNull('updateById');
            if(ret=="false"){
                return true;
            }
            layer.closeAll('loading');
            $.ajax({
                type: "POST",
                url: "${pageContext.request.contextPath }/plan/updatePlanByID.do?t=" + Math.random(),
                data: $('#updateByIdForm').serialize(),
                dataType: "json",
                success: function (result) {
                    if(result.code==-3){    //登录用户失效
                        layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath }/login.jsp">登录页面</a>');
                    }else if(result.code==-4){
                        layer.alert("您没有操作权限 ！！！");
                    }else{
                        layer.alert(result.msg);
                        if(result.code>0){
                            layer.closeAll();
                            layer.alert("操作成功 ！！！");
                            query(pNumber,pSize);
                        }
                    }
                    return false;
                },
                error: function (e) {
                    layer.closeAll('loading');
                    layer.msg("操作失败！");
                    return true;
                }
            });
            layer.closeAll('loading');
        }
        ,btn3:function(){
        	layer.closeAll();
        }
        ,cancel: function(){
        	layer.closeAll();
        }
        ,area: ['800px', '500px']
    });
   
}

//押待毕
function openStatus() { 
	$("#updateStatusDiv").remove();
    layer.open({
        title: ['费用押待毕'+'<span style="color:red;font-size:12px;margin-left:10px;">*表示该项必填</span>', 'font-size:18px;'],
        type:1,
        content: StatusHtml, //这里content是一个普通的String
        btn: ['确认', '取消'],
        yes: function(index, layero){
        	//非空验证
        	var ret = checkNull('status');
        	if(ret=="false"){
        		return true;
        	}
        	var type = $('input[name="types"]:checked');  //费用类型
        	var types="";
        	for(var i=0;i<type.length;i++){
        		types+=$(type[i]).val()+",";
        	}
            var statusType = $('input[name="statusType"]:checked').val();   //状态类型
        	if(types==null||types==undefined||types==""){
                layer.msg("请完善带*号项！");
                return true;
            }
        	if(statusType==null||statusType==undefined||statusType==""){
                layer.msg("请完善带*号项！");
                return true;
            }
        	var ids = $("#ids").val();
            var realStatus = statusType;
            var endtime = $("#endDate").val().trim();   //毕日期
            var endmemo =$("#memo").val().trim();   //毕备注
            
            if(statusType.indexOf("毕")!=-1){
                realStatus=statusType+endtime+endmemo;
            }
        	//询问是否修改
        	layer.confirm('请核查，确定要操作吗？毕掉后将无法修改！！！', function(){
        	  layer.closeAll();
	          layer.msg('正在执行，请稍等……', {icon: 16}, function(){
	        	  //$('#myModal2').modal('show');
	        	  layer.load(2);
	        	  $.ajax({
	                  type: "POST",
	                  url: "${pageContext.request.contextPath }/plan/caiwu/changeStatus.do?t=" + Math.random(),
	                  data: {id:ids,status:realStatus,types:types},
	                  cache: false,  
	                  dataType: "json",
	                  success: function (result) {
	                      if(result.code==-3){    //登录用户失效
	                          layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="login.jsp">登录页面</a>');
	                      }else if(result.code==-4){
	                          layer.alert("您没有操作权限 ！！！");
	                      }else if(result.code==-1){
	                          //layer.alert(result.msg);
	                          layer.alert('【操作失败】，提示：'+result.msg, {
	                        	  skin: 'layui-layer-lan' //样式类名
	                        	  ,closeBtn: 0
	                          });
	                      } else{
	                    	  layer.closeAll();
	                          layer.alert(result.msg);
	                          query(pNumber,pSize);
	                      }
	                      layer.closeAll('loading');
	                  },
	                  error: function (e) {
	                      layer.closeAll('loading');
	                      layer.alert("操作失败！请联系工程师……");
	                      //$('#myModal2').modal('hide');
	                      return true;
	                  }
	              });
	          });
	        });
        	layer.closeAll('loading');
        	return false;
        }
        ,btn2: function(index, layero){
        	layer.closeAll('loading');
        }
        ,cancel: function(){
        	layer.closeAll('loading');
        }
        ,area: ['800px', '500px']
    });
   $("#ids").val("");
   $("#memo").val("");
}

//流向表 上传文件的大小和格式校验
function uploadFile() {
	var ret = false;
    var maxsize = 100 * 1024 * 1024;//100M
    var name = $("#file").val();
    var ext = name.substr(name.lastIndexOf('.') + 1);
    if (ext != 'xls' && ext != 'xlsx') {//文件格式验证
        layer.msg("文件后缀只能为.xls和.xlsx!");
        $("#file").val('');
        layer.closeAll('loading');
        clicked = true;
        return ret;
    }
    var names = document.getElementById("file");
    var sizes = names.files[0].size;
    if (maxsize < sizes) {  //文件大小验证
        $("#file").val('');
        layer.msg("文件大小不能超过100M!");
        clicked = true;
        return ret;
    }
    var formData = new FormData($("#uploadForm")[0]);
    layer.msg('拼命执行中，请稍等……', {icon: 16}, function(){
    	layer.closeAll();
    	layer.load(2);
	    $.ajax({
	        type: "POST",
	        url: $('#uploadForm').attr("action"),
	        data: formData,
	        cache: false,  
	        async:true,
	        dataType: "json",
	        processData: false,
	        contentType : false,
	        success: function (result) {
	        	var code = result.code;
	        	$("#file").val("");
	       		if(code==-2){//表示上传的excel格式有错误
	       			layer.closeAll('loading');
	       			errorInfo(result.msg,"上传流向表");
	       			ret = false;
	           	}else if (code == -4){
	           		layer.closeAll('loading');
	                layer.alert("您没有操作权限！！！");
	            }else if(code==-3){	//登录用户失效
	            	layer.closeAll('loading');
	           		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
	           		ret = false;
	           	}else if(code==-1){
	           		layer.closeAll('loading');
	                layer.alert(result.msg);
	            }else{	//上传成功
	           		layer.closeAll();
	        		layer.alert("操作成功！\n"+result.msg);
	        		query(pNumber,pSize);
	        		ret = "success";
	        	}
	       		return ret;
	        },
	        error: function (e) {
	        	layer.closeAll('loading');
	            layer.msg("操作失败！");
	            ret = false;
	        }
	    });
    });
    layer.closeAll('loading');
    return ret;
}

    //是否已经点击了确定按钮，防止用户重复点击
	var clicked = false;
  	//上传流向
    function openUpload() { 
    	clicked = true;
    	$("#uploadFileForm").remove();
        layer.open({
            title: ['请选择目标【流向表Excel】文件', 'font-size:18px;'],
            type:1,
            content: uploadFileHtml, //这里content是一个普通的String
            btn: ['确认', '取消'],
            yes: function(index, layero){
            	if(clicked){
            		clicked = false;
	            	var ret = uploadFile();
	            	if(ret=='success'){
	            		return false;	//关闭框
	            	}
            	}
            }
            ,btn2: function(index, layero){
            	layer.closeAll('loading');
            }
            ,cancel: function(){
            	layer.closeAll('loading');
            }
            ,area: ['400px', '230px']
        });
    }
  	
  //上传勘误表
    function openUploadKanWu() { 
    	clicked = true;
    	$("#uploadKanWuDiv").remove();
        layer.open({
            title: ['请选择目标【勘误表Excel】文件', 'font-size:18px;'],
            type:1,
            content: uploadKanWuHtml, //这里content是一个普通的String
            btn: ['确认', '取消'],
            yes: function(index, layero){
            	if(clicked){
            		clicked = false;
            		var ret = uploadKanWuFile();
                	if(ret=='success'){
                		return false;	//关闭框
                	}
            	}
            }
            ,btn2: function(index, layero){
            	layer.closeAll('loading');
            }
            ,cancel: function(){
            	layer.closeAll('loading');
            }
            ,area: ['400px', '230px']
        });
       
    }
  
    //修改开票价、协议测算价
    function changePrice() { 
        clicked = true;
        $("#changePriceDiv").remove();
        layer.open({
            title: ['修改开票价、协议测算价', 'font-size:18px;'],
            type:1,
            content: changePriceHtml, //这里content是一个普通的String
            btn: ['取消'],
            cancel: function(){
                layer.closeAll('loading');
            }
            ,area: ['700px', '330px']
        });
       
    }
    function updatePrice(type){
    	var action = "${pageContext.request.contextPath }/plan/updatePriceByID.do";
    	var id = "";
    	var price = "";
    	if(type==1){
    		id = $("#kaipiaojiaId").val();
    		price = $("#kaipiaojia").val();
    	}else if(type==2){
    		id = $("#atsumId").val();
    		price = $("#atsumPrice").val();
    	}
    	var params ={id:id,price:price,type:type};
    	sendRequest(action, params, function(result) {
            var code = result.code;
            var cost = result.msg;
            if (code == -2) { //excel校验不通过
                open = true;
                layer.msg(result.msg);
            } else if (code == -1) { // 有错误
                layer.alert(result.msg);
            } else {
            	layer.alert(result.msg);
            }
        });
    }
    
  
  	//勘误表 上传文件的大小和格式校验
    function uploadKanWuFile() {
    	var ret = false;
        var maxsize = 100 * 1024 * 1024;//100M
        var name = $("#KanWuFile").val();
        var ext = name.substr(name.lastIndexOf('.') + 1);
        if (ext != 'xls' && ext != 'xlsx') {//文件格式验证
            layer.msg("文件后缀只能为.xls和.xlsx!");
            $("#file").val('');
            layer.closeAll('loading');
            clicked = true;
            return ret;
        }
        var names = document.getElementById("KanWuFile");
        var sizes = names.files[0].size;
        if (maxsize < sizes) {  //文件大小验证
            $("#KanWuFile").val('');
            layer.msg("文件大小不能超过100M!");
            clicked = true;
            return ret;
        }
        var formData = new FormData($("#uploadKanWuForm")[0]);
        layer.msg('拼命执行中，请稍等……', {icon: 16}, function(){
        	layer.closeAll();
        	layer.load(2);
	        $.ajax({
	            type: "POST",
	            url: $('#uploadKanWuForm').attr("action"),
	            data: formData,
	            cache: false,  
	            async:true,//需要设置成异步请求，才能加载layer.load(2);
	            dataType: "json",
	            processData: false,
	            contentType : false,
	            success: function (result) {
	            	var code = result.code;
	            	$("#KanWuFile").val("");
	           		if(code==-2){//表示上传的excel格式有错误
	           			errorInfo(result.msg,"上传勘误表");
	           			ret = false;
	               	}else if (code == -4){
	               		layer.alert("您没有操作权限！！！");
	               	}else if(code==-3){	//登录用户失效
	               		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
	               		ret = false;
	               	}else{	//上传成功
	               		layer.closeAll();
	            		layer.alert("操作成功！\n"+result.msg);
	            		query(pNumber,pSize);
	            		ret = "success";
	            	}
	           		return ret;
	            },
	            error: function (e) {
	            	layer.closeAll('loading');
	                layer.msg("操作失败！");
	                ret = false;
	            }
	        });
        });
        layer.closeAll('loading');
        return ret;
    }
    
  //计算提成
   function calculateTCOpen(type) {
   		$("#calculateTCDiv").remove();
   		layer.load(2);
   	    layer.open({
   	        title: ['提成计算', 'font-size:18px;'],
   	        type:1,
   	        content: calculateTCHtml, //这里content是一个普通的String
   	        btn: ['取消'],
   	        yes: function(index, layero){
   	        	layer.closeAll();
   	        	return true;
   	        }
   	        ,cancel: function(){
   	        	layer.closeAll('loading');
   	        	return true;
   	        }
   	        ,area: ['700px', '200px']
   	    });
   	 	layer.closeAll('loading');
    }
  
  function calculateTC(type){
	  layer.load(2);
	  if(type == "Q1"){
		  var url="${pageContext.request.contextPath }/tc/q1.do";
		  $.ajax({
	            type: "POST",
	            url: url,
	            data: {type:this.value},
	            cache: false,  
	            dataType: "json",
	            success: function (result) {
	            	layer.closeAll('loading');
		           	var code = result.code;
		      	 	if(code==-3){//登录用户失效
		           		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
		           	}else if (code == -4){
	                    layer.alert("您没有操作权限！！！");
	                } else if(code>0){
		           		layer.closeAll();
		           		layer.msg(result.msg);
		            } else if(code==-1){ // 有错误
		                layer.alert(result.msg);
		            }
	            },
	            error: function (e) {
	            	layer.closeAll('loading');
	                layer.msg("操作失败！");
	                return true;
	            }
	        });
	  }
	  if(type == "Q2"){
		  var url="${pageContext.request.contextPath }/tc/q2.do";
		  $.ajax({
	            type: "POST",
	            url: url,
	            data: {type:this.value},
	            cache: false,  
	            dataType: "json",
	            success: function (result) {
	            	layer.closeAll('loading');
		           	var code = result.code;
		      	 	if(code==-3){//登录用户失效
		           		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
		           	}else if (code == -4){
	                    layer.alert("您没有操作权限！！！");
	                } else if(code>0){
		           		layer.closeAll();
		           		layer.msg(result.msg);
		            } else if(code==-1){ // 有错误
		                layer.alert(result.msg);
		            }
	            },
	            error: function (e) {
	            	layer.closeAll('loading');
	                layer.msg("操作失败！");
	                return true;
	            }
	        });
	  }
	  if(type == "Q3"){
		  var url="${pageContext.request.contextPath }/tc/q3.do";
		  $.ajax({
	            type: "POST",
	            url: url,
	            data: {type:this.value},
	            cache: false,  
	            dataType: "json",
	            success: function (result) {
	            	layer.closeAll('loading');
		           	var code = result.code;
		      	 	if(code==-3){//登录用户失效
		           		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
		           	} else if (code == -4){
	                    layer.alert("您没有操作权限！！！");
	                } else if(code>0){
		           		layer.closeAll();
		           		layer.msg(result.msg);
		            } else if(code==-1){ // 有错误
		                layer.alert(result.msg);
		            }
	            },
	            error: function (e) {
	            	layer.closeAll('loading');
	                layer.msg("操作失败！");
	                return true;
	            }
	        });
	  }
	  if(type == "Q4"){
		  var url="${pageContext.request.contextPath }/tc/q4.do";
		  $.ajax({
	            type: "POST",
	            url: url,
	            data: {type:this.value},
	            cache: false,  
	            dataType: "json",
	            success: function (result) {
	            	layer.closeAll('loading');
		           	var code = result.code;
		      	 	if(code==-3){//登录用户失效
		           		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
		           	}else if (code == -4){
	                    layer.alert("您没有操作权限！！！");
	                } else if(code>0){
		           		layer.closeAll();
		           		layer.alert(result.msg);
		            } else if(code==-1){ // 有错误
		                layer.alert(result.msg);
		            }
	            },
	            error: function (e) {
	            	layer.closeAll('loading');
	                layer.msg("操作失败！");
	                return true;
	            }
	        });
	  } 
 }

  //$("#keyTerminalDiv").remove();
    //重点终端、好伙伴
    function openkeyTerminal(type) {
    	console.log(type);
    	if(type=="好伙伴"){
    		keyTerminalHtml= goodFriendHtml;
    		$("#key").text(type);
    		//$("#keyTerminalDiv").remove();
    	}
    	if($("#keyTerminalDiv").length > 0) {
    		$("#keyTerminalDiv").remove();
    	} 
    	//keyTerminalHtml=$("#keyTerminalDiv").html();
   		//$("#keyTerminalDiv").remove();
   		
   		layer.load(2);
   	    layer.open({
   	        title: [type+'<span style="color:red;font-size:12px;margin-left:10px;">*表示该项必填</span>', 'font-size:18px;'],
   	        type:1,
   	        content: keyTerminalHtml, //这里content是一个普通的String
   	        btn: ['确认', '取消'],
   	        yes: function(index, layero){
   	        	//非空验证
   	        	var ret = checkNull('key');
   	        	if(ret=="false"){
   	        		return true;
   	        	}
   	        	var keyIds = $("#keyTerminalId").val();
   	        	var terminalName = $("#terminalName").val();
   	        	var group = $('input[name="group"]:checked').val();	//分组标识
   	        	var revise = $('input[name="revise"]:checked').val();	//修订标识
   	        	$.ajax({
   	                type: "POST",
   	                url: "${pageContext.request.contextPath }/plan/changeKeyTerminal.do?t=" + Math.random(),
   	                data: {keyIds:keyIds,terminalName:terminalName,group:group,revise:revise,type:type},
   	                cache: false,  
   	                dataType: "json",
   	                success: function (result) {
   	                	if(result.code==-3){	//登录用户失效
   	                		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath }/login.jsp">登录页面</a>');
   	                	}else if (code == -4){
   	                     layer.alert("您没有操作权限！！！");
   	                   }else{
   	                		layer.msg(result.msg);
   	                	}
   	                },
   	                error: function (e) {
   	                	layer.closeAll('loading');
   	                    layer.msg("操作失败！");
   	                    return true;
   	                }
   	            });
   	        	layer.closeAll('loading');
   	        	//return false;
   	        }
   	        ,btn2: function(index, layero){
   	        	layer.closeAll('loading');
   	        }
   	        ,cancel: function(){
   	        	layer.closeAll('loading');
   	        }
   	        ,area: ['700px', '300px']
   	    });
    }
    
    
    function openMoneyType() {
        $('#chooseMoneyType').modal();
    }
    var total = 0;
  //异步请求获取符合筛选条件的流向记录
    function query(pageNumber, pageSize){
	  
    	var url = "${pageContext.request.contextPath }/plan/selectPlanList.do?pageNumber="
            + pageNumber + "&pageSize=" + pageSize;
        var params = $("#filterForm").serialize();
        queryList(url,params);
    };
    	//toggleCondi_hidden();
	  	/*var plansId = $("#plansId").val();
        var mgr = $("#mgr").val();
        var terminalQs = $("#terminalQs").val();
        var fenbu = $("#fenbu").val();
        var daibiao = $("#daibiao").val();
        var tichengbelong = $("#tichengbelong").val();
        var client = $("#client").val();
        var terminal = $("#terminal").val();
        var commercial1 = $("#commercial1").val();
        var policyId = $("#policyId").val();
        var month = $("#month").next("div").find("button").attr("title");
        var product = $("#product").next("div").find("button").attr("title");
        var judge = $("#judge").next("div").find("button").attr("title");
        var pack = $("#pack").next("div").find("button").attr("title");
        var mode = $("#mode").next("div").find("button").attr("title");
        var xieyizhuangtai = $("#xieyizhuangtai").next("div").find("button").attr("title");
        var terminaltype = $("#terminaltype").next("div").find("button").attr("title");
        var kaipiaofangshi = $("#kaipiaofangshi").next("div").find("button").attr("title");
        var jsmode = $("#jsmode").next("div").find("button").attr("title");
        var province = $("#province").next("div").find("button").attr("title");
        var year = $("#year").next("div").find("button").attr("title");
        var city = $("#city").next("div").find("button").attr("title");
        var county = $("#county").next("div").find("button").attr("title");
        var daqu = $("#daqu").next("div").find("button").attr("title");
        var space = $("#space").next("div").find("button").attr("title");
        var money6 = $("#later").val();
        var plan_check = $("#plan_check").val();
        var unqualified = $("#unqualified").val();
        var isToday = $("#isToday").val();
        var status3 = $("#status3").next("div").find("button").attr("title");
        var tcstatus = $("#tcstatus").next("div").find("button").attr("title");
        var status1 = $("#status1").next("div").find("button").attr("title");
        var status4 = $("#status4").next("div").find("button").attr("title");
        var status5 = $("#status5").next("div").find("button").attr("title");
        var statusMgr = $("#statusMgr").next("div").find("button").attr("title");
        var condiMap = {
        		id:plansId,policyId:policyId,
            terminalQs:terminalQs,mgr:mgr,fenbu:fenbu,daibiao:daibiao,tichengbelong:tichengbelong, 
            client:client,	terminal:terminal,	commercial1:commercial1,
            month:month, 	product:product,	judge:judge,	pack:pack,	mode:mode,	xieyizhuangtai:xieyizhuangtai,	terminaltype:terminaltype,
            kaipiaofangshi:kaipiaofangshi,	jsmode:jsmode, province:province,  year:year,	city:city,
            county:county,	daqu:daqu,	space:space,money6:money6, 	status6:plan_check,unqualified:unqualified,	today:isToday,
            pageNumber:pageNumber,status3:status3,tcstatus:tcstatus,status1:status1,status4:status4,status5:status5,statusMgr:statusMgr,
            pageSize:pageSize
        }
        layer.load(2);
        $.ajax({
            type:"POST",
            url:"${pageContext.request.contextPath }/plan/selectPlanList.do?t=" + Math.random(),
            data:condiMap,
            dataType : "json",
            success: function(result) {
            	$("#distribute-body").html("");
                $(".pageBottom").css('display','none');
                if(result.code==-3){	//登录用户失效
               		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath }/login.jsp">登录页面</a>');
               	}else if(result==null) { 
                    layer.msg("筛选后的记录数为零！");
                }else if(result.total==0){
                	layer.msg("筛选后的记录数为零！");
                }else{
                	total = result.total;
                    if(result.pageNum==1){
                        $('#callBackPager').extendPagination({
                            totalCount: result.total,
                            showPage: pSize,
                            pageNum:result.pageNum,
                            limit: result.pageSize,
                            callback: function (curr, limit, totalCount) {
                                query(curr, limit);
                            }
                        });
                    }
                    $(".pageBottom").css('display','block');
                    createTable(result.pageNum, result.pageSize, result.total, result.list);
                    $("#pageNumber").text(result.pageNum);
                }
               // $(".sidebar-toggle-box").click();
                layer.closeAll('loading');
            },
            error: function(e){
                layer.closeAll('loading');
                layer.msg("操作失败！");
            }
        });*/
    

    //动态创建table
    function createTable(currPage, limit, total, items) {
        var html = [], showNum = limit;
        if (total - (currPage * limit) < 0) showNum = total - ((currPage - 1) * limit);
        for (var i = 0; i < showNum; i++) {
        	html.push("<tr ondblclick=\"showOpen('"+items[i].id+"','修改流向')\" >");
        	html.push('<td><input type="checkbox" name="choice" value="'+items[i].id+'"/></td>');
        	html.push('<td>' + formatData(items[i].sdate) + '</td>');
        	html.push('<td>' + formatData(items[i].space) + '</td>');
        	html.push('<td>' + formatData(items[i].commercial1) + '</td>');
        	html.push('<td>' + formatData(items[i].judge) + '</td>');
        	html.push('<td>' + formatData(items[i].terminal) + '</td>');
        	html.push('<td>' + formatData(items[i].zhenghe_qs) + '</td>');
        	html.push('<td>' + formatData(items[i].province)+ '/' + formatData(items[i].mgr)+ '/' +formatData(items[i].tichengbelong)+ '</td>');
        	html.push('<td>' + formatData(items[i].clientpolicyId)+ '</td>');
        	html.push('<td>' + formatData(formatData(items[i].policystatus)+ '/' +items[i].kaipiaofangshi)  + '</td>');
        	html.push('<td>' + formatData(items[i].product)+ formatData(items[i].pack)+ '/' +formatData(items[i].mode) + '</td>');
        	html.push('<td>' + formatData(items[i].count) + '</td>');
        	html.push('<td>' + formatData(items[i].client)+ '/' + formatData(items[i].xieyizhuangtai)+ '/' + formatData(items[i].daibiao)+'</td>');
        	html.push('<td>' + formatData(items[i].jsmode) + '</td>');
        	html.push('<td>' + formatData(items[i].basic1) + '</td>');
        	html.push('<td>' + formatData(items[i].money1) + '</td>');
        	html.push('<td>' + formatData(items[i].status1) + '</td>');
        	html.push('<td>' + formatData(items[i].piaoju3) + '</td>');
        	html.push('<td>' + formatData(items[i].money3) + '</td>');
        	html.push('<td>' + formatData(items[i].status3) + '</td>');
        	html.push('<td>' + formatData(items[i].dabiao4) + '</td>');
        	html.push('<td>' + formatData(items[i].money4) + '</td>');
        	html.push('<td>' + formatData(items[i].status4) + '</td>');
        	html.push('<td>' + formatData(items[i].totalmoney) + '</td>');
        	html.push('<td>' + formatData(items[i].kaifa5) + '</td>');
        	html.push('<td>' + formatData(items[i].money5) + '</td>');
        	html.push('<td>' + formatData(items[i].status5) + '</td>');
        	
        	html.push('<td>' + formatData(items[i].kaifaMgr) + '</td>');
        	html.push('<td>' + formatData(items[i].moneyMgr) + '</td>');
        	html.push('<td>' + formatData(items[i].statusMgr) + '</td>');
        	
        	html.push('<td>' + formatData(items[i].daqu) + '</td>');
        	html.push('<td>' + formatData(items[i].city) + '</td>');
        	html.push('<td>' + formatData(items[i].county) + '</td>');
        	html.push('<td>' + formatData(items[i].xsScount) + '</td>');
        	html.push('<td>' + formatData(items[i].scount) + '</td>');
        	html.push('<td>' + formatData(items[i].pihao) + '</td>');
        	html.push('<td>' + formatData(items[i].fenbu) + '</td>');
        	html.push('<td>' + formatData(items[i].terminaltype) + '</td>');
        	html.push('<td>' + formatData(items[i].terminallev) + '</td>');
        	
        	html.push('<td>' + formatData(items[i].cuxiao_ed_money) + '</td>');
        	html.push('<td>' + formatData(items[i].peisonglv) + '</td>');
        	html.push('<td>' + formatData(items[i].yinyukaiguan) + '</td>');
        	html.push('<td>' + formatData(items[i].yingyumoney) + '</td>');
        	html.push('<td>' + formatData(items[i].atsum) + '</td>');
        	
        	html.push('<td>' + formatData(items[i].zhongbiaojiamoney) + '</td>');
        	html.push('<td>' + formatData(items[i].kaipiaojiamoney) + '</td>');
        	html.push('<td>' + formatData(items[i].daquTcMan) + '</td>');
        	html.push('<td>' + formatData(items[i].zgTcMan) + '</td>');
        	html.push('<td>' + formatData(items[i].gxTcMan) + '</td>');
        	html.push('<td>' + formatData(items[i].danwitichen) + '</td>');
        	html.push('<td>' + formatData(items[i].shijiticheng) + '</td>');
        	html.push('<td>' + formatData(items[i].spaceZLDanwei) + '</td>');
        	html.push('<td>' + formatData(items[i].spaceZLTc) + '</td>');
        	html.push('<td>' + formatData(items[i].spaceKouJian) + '</td>');
        	html.push('<td>' + formatData(items[i].spaceKouJianTc) + '</td>');
        	html.push('<td>' + formatData(items[i].gaoJieDanwei) + '</td>');
        	html.push('<td>' + formatData(items[i].gaoJieTc) + '</td>');
        	html.push('<td>' + formatData(items[i].gxDanwei) + '</td>');
        	html.push('<td>' + formatData(items[i].gxTc) + '</td>');
        	html.push('<td>' + formatData(items[i].zgDanwei) + '</td>');
        	html.push('<td>' + formatData(items[i].zgTc) + '</td>');
        	html.push('<td>' + formatData(items[i].zgDanwei_zl) + '</td>');
        	html.push('<td>' + formatData(items[i].zgTc_zl) + '</td>');
        	html.push('<td>' + formatData(items[i].jicengbutie7) + '</td>');
        	html.push('<td>' + formatData(items[i].money7) + '</td>');
        	html.push('<td>' + formatData(items[i].daquZLDanwei) + '</td>');
        	html.push('<td>' + formatData(items[i].daquZLTc) + '</td>');
        	html.push('<td>' + formatData(items[i].daquKouJian) + '</td>');
        	html.push('<td>' + formatData(items[i].daquKouJianTc) + '</td>');
        	html.push('<td>' + formatData(items[i].jianli) + '</td>');
        	html.push('<td>' + formatData(items[i].tcstatus) + '</td>');
        	html.push('<td>' + formatData(items[i].focusonFlag) + '</td>');
        	html.push('<td>' + formatData(items[i].goodFriendFlag) + '</td>');
        	html.push('<td>' + formatData(items[i].money6) + '</td>');
        	html.push('<td>' + formatData(items[i].status6) + '</td>');
        	html.push('<td>' + formatData(items[i].unqualified) + '</td>');
        	html.push('<td>' + formatData(items[i].demo) + '</td>');
        	html.push('<td>' + formatData(items[i].shoukuangren) + '</td>');
        	html.push('<td>' + formatData(items[i].kaihuhang) + '</td>');
        	html.push('<td>' + formatData(items[i].zhanghao) + '</td>');
        	html.push('<td>' + formatData(items[i].id) + '</td>');
        	html.push('<td>' + formatData(items[i].dataer) + '</td>');
        	html.push('<td>' + formatData(items[i].today) + '</td>');
            html.push('</tr>');
        }
        var mainObj = $('#distribute-body');
        mainObj.empty();
        mainObj.html(html.join(''));
    };

    function errorInfo(items,type){
       var check_val = "";
	   var html = [];
	   for (var i = 0; i < items.length; i++) {
		   html.push("<tr>");
		   html.push('<td>' + items[i].err_num.substring(items[i].err_num.indexOf("：")+1)+ '</td>');
           html.push('<td>' + formatData(items[i].err_title) + '</td>');
           html.push('<td style="color:#479DA4;">' + formatData(items[i].err_msg) + '</td>');
           html.push('<td >' + formatData(items[i].err_field) + '</td>');
           html.push('</tr>');
           check_val += formatData(items[i].err_field)+"\n";
	   }
	   var mainObj = $('#error-body');
       mainObj.empty();
       mainObj.html(html.join(''));
       
       var errorInfoHtml = $("#errorInfoDiv").html();
       layer.open({
           title: ['错误信息', 'font-size:18px;'],
           type:1,
           content: errorInfoHtml//这里content是一个普通的String
           ,btn: ['双击复制错误信息', '取消']
           ,yes: function(index, layero){
               var copy = $(".layui-layer-btn0");
               for(var k=0; k<copy.length;k++){
                   if(copy[k].innerText=='双击复制错误信息'){
                       $(".layui-layer-btn0").zclip({
                           path:'http://img3.job1001.com/js/ZeroClipboard/ZeroClipboard.swf',
                           copy:function(){
                                  var ids = check_val;  
                                  if(ids.trim().length>0){
                                      return ids;
                                  }else{
                                      layer.msg("您没有选中行！");
                                  }
                               },
                           afterCopy:function(){layer.msg("复制成功！");}
                       });
                   }
               }
          }
          ,btn2: function(index, layero){
        	  layer.closeAll('loading');
        	  if(type === "上传流向表"){
        		  openUpload();
        	  } else if(type === "上传勘误表"){
        		  openUploadKanWu();
        	  }
          }
          ,cancel: function(){
        	  layer.closeAll('loading');
			  if(type === "上传流向表"){
				  openUpload();
        	  } else if(type === "上传勘误表"){
        		  openUploadKanWu();
        	  }
          }
          ,area: ['800px', '400px']
     });
		$("#error-info").removeAttr("hidden");
   }
    
    //格式化无效数据
    function formatData(data) {
        if (data && data != null) {
            return data;
        } else {
            return "";
        }
    }
	    
  //查询按钮绑定回车键
    $("body").keydown(function() {
        if (event.keyCode == "13") {//keyCode=13是回车键
            $('#seach').click();
        }
    });
  
    function checkNull(type){
    	var noNull = $(".noNull");
    	if(type=='updateById'){
    		noNull = $("#updateByIdForm").find(".noNull");
    	}else if(type=='key'){
    		noNull = $("#keyTerminalForm").find(".noNull");
    	}else if(type=='status'){
    		noNull = $("#updateStatusForm").children().find(".noNull");
    	}else if(type=='change'){
    		noNull = $("#planForm").find(".noNull");
    	}
		for(var i=0;i<noNull.length;i++){
			if(noNull[i].value==null||noNull[i].value==undefined||noNull[i].value==""){
				layer.msg("请完善带*号项！");
				return "false";
			}
		}
		return "true";
    }
</script>
<script type="text/javascript">

function chooseRevise(type){
	if(type=='E'){	//修改
		/* $("#terminalName").attr("readonly","readonly"); */
		$("#terminalName").val("");
		$("#keyTerminalId").removeAttr("readonly");
		$("#keyTerminalId").addClass("noNull");
		$("#terminalName").removeClass("noNull");
		$("#keyTerminalId").after('&nbsp;<span style="color:red;">*</span>');
		$("#terminalName").next("span").remove();
	}else if(type=='N'){	//新增
		$("#keyTerminalId").attr("readonly","readonly");
		$("#keyTerminalId").val("");
		$("#terminalName").removeAttr("readonly");
		$("#terminalName").addClass("noNull");
		$("#keyTerminalId").removeClass("noNull");
		$("#terminalName").after('&nbsp;<span style="color:red;">*</span>');
		$("#keyTerminalId").next("span").remove();
	}
}
/* $("#keyTerminalId").blur(function(){
	$("#keyTerminalId").after("<i>After</i>");
}); */
function blurCheck(t){
	/* if(t.value==''){
		t.after("<span style='color:red;font-size:12px;margin-left:10px;'>该项必填</span>");
	} */
	
}

function deletePlan(){
	$("#deleteDiv").remove();
	layer.open({
	        title: ['删除流向', 'font-size:18px;'],
	        type:1,
	        content: deleteHtml, // 这里content是一个普通的String
	        btn: ['删除', '取消'],
	        yes: function(index, layero){
	        	var ids = $("#idD").val();
	        	if(ids.trim().length<=0){
	        		layer.alert("ID不能为空！！！");
	        		return;
	        	}
	        	layer.confirm('确认要删除['+ids+']吗？', {
	                btn : [ '确认', '取消' ] //按钮
	            }, function(index) {
	                layer.close(index);
	                //去执行删除操作 
	                $.ajax({ 
	                    type: "POST",
	                    async:false,//同步
	                    url: "${pageContext.request.contextPath }/plan/delPlan.do?t=" + Math.random(),
	                    data: {id:ids},
	                    dataType: "json",
	                    success: function (result) {
	                    	var code = result.code;
	                    	if(code==-3){	//登录用户失效
	                       		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath }/login.jsp">登录页面</a>');
	                       	}else if (code == -4){
	                            layer.alert("您没有操作权限！！！");
	                        }else if(code>0){
	                       		layer.closeAll();
	                       		layer.alert(result.msg);
	                       		query(pNumber,pSize);
	                       	}else{
	                       		layer.alert(result.msg);
	                       	}
	                    },
	                    error: function (e) {;
	                        layer.closeAll('loading')
	                        layer.msg("操作失败！");
	                    }
	                });
	            }); 
	        	
	        }
	        ,btn2: function(index, layero){
	        	layer.closeAll('loading');
	        }
	        ,cancel: function(){
	        	layer.closeAll('loading');
	        }
	        ,area: ['700px', '180px']
	    });

	$("#error-info").removeAttr("hidden");	
}

function resetf(){
	location.reload();
}
//对勘误表的操作
function showKanWu(){
	$("#kanWuDiv").remove();
	layer.open({
	        title: ['勘误流向表', 'font-size:18px;'],
	        type:1,
	        content: kanWuHtml, // 这里content是一个普通的String
	        btn: ['确认', '取消'],
	        yes: function(index, layero){
                //去执行修改操作
                $.ajax({ 
                    type: "POST",
                    async:false,//同步
                    url: "${pageContext.request.contextPath }/plan/errataUpdate.do?t=" + Math.random(),
                    data: $('#kanWuForm').serialize(),
                    dataType: "json",
                    success: function (result) {
                    	layer.closeAll('loading');
                    	var code = result.code;
                    	if(code==-3){	//登录用户失效
                       		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
                       	}else if (code == -4){
                            layer.alert("您没有操作权限！！！");
                        }else if(code>0){
                       		layer.closeAll();
                       		layer.msg(result.msg);
                        	query(pNumber,pSize);
                        }else if(code==-2){ //excel校验不通过
                        	errorInfo(result.msg,"上传勘误表");
                        }else if(code==-1){ // 有错误
                        	layer.alert(result.msg);
                        }
                        return false;
                    },
                    error: function (e) {;
                        layer.closeAll('loading')
                        layer.msg("操作失败！");
                    }
                });
	        }
	        ,btn2: function(index, layero){
	        	layer.closeAll('loading');
	        }
	        ,cancel: function(){
	        	layer.closeAll('loading');
	        }
	        ,area: ['800px', '480px']
	    });

	$("#error-info").removeAttr("hidden");	
}

//下载库存
function download_kucun(endTime) {
    $('#myModal1').modal('show');
    //调用进度条
    start_progress();
    action = "${pageContext.request.contextPath }/plan/downloadTimeInventory.do?endTime="+endTime;
}

//下载时间理论库存
function openUploadTime(){
	$("#timeDiv").remove();
	layer.open({
        title: ['下载时间理论库存', 'font-size:18px;'],
        type:1,
        content: timeHtml, // 这里content是一个普通的String
        btn: ['确认', '取消'],
        yes: function(index, layero){
        	layer.closeAll();
        	//获取截止日期
        	var endTime = $("#endTime").val();
        	download_kucun(endTime);
        }
        ,btn2: function(index, layero){
        	layer.closeAll('loading');
        }
        ,cancel: function(){
        	layer.closeAll('loading');
        }
        ,area: ['500px', '180px']
    });
}

//给销售或纯销流向赋值政策
function initpolicy(){
	$("#initDiv").remove();
	layer.open({
        title: ['给销售或纯销流向赋值政策', 'font-size:18px;'],
        type:1,
        content: initHtml, // 这里content是一个普通的String
        btn: ['确认匹配', '取消'],
        yes: function(index, layero){
        	//获取流向Id和协议Id
        	var planId = $("#plan_Id").val();
        	var policyId = $("#policy_Id").val();
        	//alert(planId+","+policyId);
            //去修改操作
        	$.ajax({ 
                type: "POST",
                async:true,
                url: "${pageContext.request.contextPath }/plan/initPolicy.do?t=" + Math.random(),
                data: {plan_Id:planId,policy_Id:policyId},
                dataType: "json",
                success: function (result) {
                	 layer.closeAll('loading');
                	 var code = result.code;
           	 		 if(code==-3){	//登录用户失效
                		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
                	 }else if (code == -4){
                         layer.alert("您没有操作权限！！！");
                     }else if(code>0){
                		layer.closeAll();
                		layer.msg(result.msg);
                 	    query(pNumber,pSize);
	                 }else if(code==-1){ // 有错误
	                 	layer.alert(result.msg);
	                 }
                 return false;
                },
                error: function (e) {;
                    layer.closeAll('loading')
                    layer.msg("操作失败！");
                }
            }); 
        }
        ,btn2: function(index, layero){
        	layer.closeAll('loading');
        }
        ,cancel: function(){
        	layer.closeAll('loading');
        }
        ,area: ['680px', '260px']
    });
}

//下载勘误表
function downloadErrata(){
	$.ajax({ 
        type: "POST",
        async:true,
        url: "${pageContext.request.contextPath }/plan/errata_download.do?t=" + Math.random(),
        dataType: "json",
        success: function (result) {
        	 layer.closeAll('loading');
        	 var code = result.code;
        	 if(code==-3){	//登录用户失效
        		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
        	 }else if (code == -4){
                 layer.alert("您没有操作权限！！！");
             }else if(code>0){
        		layer.closeAll();
        		layer.msg(result.msg);
        		query(pNumber,pSize);
	         }else if(code==-1){ // 有错误
	         	layer.alert(result.msg);
	         }
	         return false;
        },
        error: function (e) {;
            layer.closeAll('loading')
            layer.msg("操作失败！");
        }
    });
}
//系统提单
function systemBL(){
	$("#systemBLDiv").remove();
	layer.open({
        title: ['系统提单', 'font-size:18px;'],
        type:1,
        content: systemBLHtml, // 这里content是一个普通的String
        btn: ['确认', '取消'],
        yes: function(index, layero){
        	
        }
        ,btn2: function(index, layero){
        	layer.closeAll('loading');
        }
        ,cancel: function(){
        	layer.closeAll('loading');
        }
        ,area: ['680px', '260px']
    });
}

function spacesBL(){
	$("#spacesDiv").remove(); 
	layer.open({
        title: ['片区提单', 'font-size:18px;'],
        type:1,
        content: spacesHtml, // 这里content是一个普通的String
        btn: ['确认', '取消'],
        yes: function(index, layero){
        	var spaces = $("#spaceBL").next("div").find("button").attr("title");
        	spaces_BL(spaces);
        }
        ,btn2: function(index, layero){
        	layer.closeAll('loading');
        }
        ,cancel: function(){
        	layer.closeAll('loading');
        }
        ,area: ['360px', '480px']
    });
	$('#spaceBL').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择片区',enableFiltering: true,maxHeight:300,buttonWidth: '150px'});
}

function spaces_BL(flag) {
	layer.load(2);
    if(flag=='all'){//全国
    	action = "${pageContext.request.contextPath }/tidan/all.do?t=" + Math.random();
    }else{//片区
    	//alert(flag);
    	action = "${pageContext.request.contextPath }/tidan/bySpace.do?spaces="+flag+"&t=" + Math.random();
    }
    $.ajax({ 
        type: "POST",
        async:true,
        url: action,
        dataType: "json",
        success: function (result) {
        	layer.closeAll('loading');
        	var code = result.code;
     	 	if(code==-3){	//登录用户失效
        		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
        	}else if (code == -4){
                layer.alert("您没有操作权限！！！");
            }else if(code>0){
        		layer.closeAll();
        		layer.msg(result.msg);
	        }else if(code==-1){ // 有错误
	         	layer.alert(result.msg);
	        }
         return false;
        },
        error: function (e) {;
            layer.closeAll('loading')
            layer.msg("操作失败！");
        }
    });
    
}

function sumInfo(items){    
    var html = [];
    for(var i=0;i<items.length;i++){ 
    	html.push("<tr>");
        html.push('<td>' + formatData(items[i].mode)+ '</td>');
        html.push('<td>' + formatData(items[i].counts)+ '</td>');
        html.push('<td>' + formatData(items[i].scount) + '</td>');
        html.push('<td>' + formatData(items[i].money1) + '</td>');
        html.push('<td>' + formatData(items[i].money3) + '</td>');
        html.push('<td>' + formatData(items[i].money4) + '</td>');
        html.push('<td>' + formatData(items[i].totalMoney) + '</td>');
        html.push('<td>' + formatData(items[i].money5) + '</td>');
        html.push('<td>' + formatData(items[i].moneyMgr) + '</td>');
        html.push('</tr>');
    }
    var mainObj = $('#sum-body');
    mainObj.empty();   
    mainObj.html(html.join(''));
    
    var calSumHtml = $("#calSumDiv").html();
    layer.open({
         title: ['计算总和', 'font-size:18px;'],
         type:1,
         content: calSumHtml  //这里content是一个普通的String
         ,cancel: function(){
        	 layer.closeAll('loading');
             return true;
         }
         ,area: ['800px', '400px']
     });

     $("#sum-info").removeAttr("hidden");
}

function calSum(){
    layer.load(2);
    $.ajax({ 
        type: "POST",
        async:true,
        url: "${pageContext.request.contextPath }/plan/selectSumBy.do?t=" + Math.random(),
        dataType: "json",
        success: function (result) {
            //alert(result);
            sumInfo(result);
            layer.closeAll("loading");
        },
        error: function (e) {;
            layer.closeAll('loading')
            layer.msg("操作失败！");
        }
    });
}

function scrollToLeft(){
    var div = $("#canvas-wrap");
    var position = 0;
    console.log("position:"+position);
    div[0].scrollLeft  = position;
}

function scrollToCenter(){
	var div = $("#canvas-wrap");
	var position = (div[0].scrollWidth  - div.width()) / 2;
    console.log("position:"+position);
    div[0].scrollLeft  = position;
}
function scrollToCenter1(){
	var div = $("#canvas-wrap");
	var position = (div[0].scrollWidth  - div.width()) / 6;
    console.log("position:"+position);
    div[0].scrollLeft  = position;
}
function scrollToCenter2(){
	var div = $("#canvas-wrap");
	var position = (div[0].scrollWidth  - div.width()) / 3;
    console.log("position:"+position);
    div[0].scrollLeft  = position;
}

function scrollToRight(){
    var div = $("#canvas-wrap");
    var position = div[0].scrollWidth  - div.width();
    console.log("position:"+position);
    div[0].scrollLeft  = position;
}
function scrollToRight2(){
    var div = $("#canvas-wrap");
    var position = (div[0].scrollWidth  - div.width()) / 1.5;
    console.log("position:"+position);
    div[0].scrollLeft  = position;
}
function scrollToRight3(){
    var div = $("#canvas-wrap");
    var position = (div[0].scrollWidth  - div.width()) / 1.2;
    console.log("position:"+position);
    div[0].scrollLeft  = position;
}

function getProp(){
    obj = document.getElementsByName("choice");
    var check_val = "";
    for(k in obj){
        if(obj[k].checked)
            check_val = check_val+" "+ obj[k].value
    }
    return check_val;
}
//所有选中的id
var selectedIds = "";
//全选或全不选
$("#allAndNotAll").click(function() { 
    if (this.checked){  
        $("input[name='choice']:checkbox").each(function(){ 
              $(this).attr("checked", true);  
        });
        layer.msg('拼命执行中，请稍等……', {icon: 16}, function(){
        	layer.closeAll();
        	layer.load(2);
        	//发送异步请求，获取数据
            sendRequest(pageContextPath + "/plan/selectIds.do", null, function (jsonData) {
                selectedIds = jsonData.ids;
                layer.closeAll();
            });
        });
      	
    } else {   
        $("input[name='choice']:checkbox").each(function() {   
              $(this).attr("checked", false);  
        });
        selectedIds="";
    }  
});
</script>

<style type="text/css">
.ui-com {
	font-size: 14px;
	max-height: 100px;
	max-width: 172px;
	overflow-y: auto;
	/* 防止水平滚动条 */
	overflow-x: hidden;
}

.Textwrap {
	width: 150px;
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
}
.radio{
    margin-left:25px;
}
</style>

<!-- 自定义的script方法 -->
<script type="text/javascript">
var p = 0;
var miao = 0;
var stop = 0;
var url;
var count=0;
var action = "no_request";
//启动进度条
function start_progress() {
    miao += 1;
    if(p == 100){
        p = 0;
    }
    p += 10; //进度条每秒走10个单位
    if(stop==1){//ajax返回success时，stop=1
        $("#sucessufl_bar").css("width", "100%");//进度条完成100%
        $('#myModal1').modal('hide');//隐藏模板
        count = 0;//还原count
        stop = 0;//还原stop
        miao = 0;//还原miao
        action = "no_request";//还原action
        //window.open(url);大部分浏览器会阻止弹框
        var f = document.createElement("form");
        f.target = '_blank';
        f.method = 'POST';
        document.body.appendChild(f);
        var i = document.createElement("input");
        i.type = "hidden";
        f.appendChild(i);
        i.value = "5";
        i.name = "price";
        f.action = url; //下载的url 地址
        f.submit();
        return;
    }
    $("#sucessufl_bar").css("width", p + "%");
    $("#miao").html(miao);
    if(count == 1){
    	sendRequest(action, null, function (jsonData) {
            stop = jsonData.sucessful;
            var filePath  = jsonData.filePath;
            url = pageContextPath+filePath;
        },true);
 	}
    count += 1;
    //每秒执行一次
    var timer = setTimeout("start_progress()", 1000);
}
</script>

<script type="text/javascript">
    $(function(){
        var value = new Date().getFullYear()+'/'+(new Date().getMonth()+1) + '/' + new Date().getDate();
        $("#endDate").val(value);
    });
    
    function clearText(id){
    	$("#"+id+"").val("");
    }
</script>
